Jump to content
UBot Underground

New v4 Tutorial (Multi Threading Example)


Recommended Posts

I have TJ's free mem and helps a lot. The browser is eating most of your mem.

 

If you have HTTP plugin from Aymen and make your bots use sockets  you can run 500 threads no sweat, if you have the internet.

 

I was playing with my version of sockets public proxy checker and I was sooo amazed when I kept increasing the thread count.

 

CPU and Mem did not change much at all. Didn't use free memory either.

Link to post
Share on other sites
  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Her eis example code you can use for multi threading that is very simple to setup and use with "most" applications.   ui drop down("Thread Count", "2,3,4,5,6,7,8,9,10", #num threads) ui text box("Num

Here's a Multi Threading Example that TJ helped me with that processes a list with 3 elements per row. I originally tried to use TJ's Advanced example using Tables but found that the multi threading w

Using the above example how would I loop thru multiple list? I have a list of post I would like to run thru that are specific for each login. So user A logs in and post from user A list (schedule), th

Hey i have been using it and i dont think memory is the issue. 

ive got 32 gigs of ram and 360 gigs ssd. even if im running low threads, lets say 10. threads are still dying and before an hour ill be at 0 threads working

Link to post
Share on other sites
  • 1 month later...

I have TJ's free mem and helps a lot. The browser is eating most of your mem.

 

If you have HTTP plugin from Aymen and make your bots use sockets  you can run 500 threads no sweat, if you have the internet.

 

I was playing with my version of sockets public proxy checker and I was sooo amazed when I kept increasing the thread count.

 

CPU and Mem did not change much at all. Didn't use free memory either.

I have a question with using the HTTP plugin and running multi threaded should I be using "in new browser" or is fine just run in new thread.  I seem to keep having threads running and not closing off properly and just wondering if this is why.

Link to post
Share on other sites
  • 2 weeks later...

In the main post, I don't think we need this line:

if($comparison(#num created, "<", #number accounts)) {

 

Because the loop argument takes care of that: loop(#number accounts) {

 

(it only runs the loop so many times)

 

Let me know if I'm wrong.

 

Thanks,

Marton

Link to post
Share on other sites

It's a double check tracker to make sure the threads font go past the point you need them to. Just like its checked again in the code here define usually. Don't want and random threads running wild so to validate information mine as well add a couple check points

Link to post
Share on other sites

It's a double check tracker to make sure the threads font go past the point you need them to. Just like its checked again in the code here define usually. Don't want and random threads running wild so to validate information mine as well add a couple check points

 

But it's not needed. It's impossible that it would go past it. Think about it. Example: we want 10 accounts.

 

loop(#number accounts)

 

So it will loop the whole thing 10 times. (not less, not more). = It's impossible that it will create more than 10 account regardless of how many threads it uses at a time.

Link to post
Share on other sites

Hot a bit new around here. When it comes to multi threading in ubot we've seen some strange things round here. So the check if not needed for you feel free to remove it. I have in some of my uses as well. But I normally have some sort if check for validation.

Link to post
Share on other sites

Ok, thank you for the reply. More important question:
Instead of:

define loop process {
    increment(#used threads)
    increment(#num created)
    registration procedure()

Shouldn't the order be:

define loop process {
    increment(#used threads)
    registration procedure()
    wait(0.5)
    increment(#num created)

Otherwise It won't create the very last account, because of:
if($comparison(#num created, "<", #number accounts))

 

?

p.s.: I added the 0.5 second delay, to make sure it runs the comparison first (hopefully that's enough delay)

Link to post
Share on other sites

As a general rule it's considered bad coding habit to add double checks where they are not needed (it might cause problems like the one I just showed). I think that comparison should rather be deleted, because that delay is not the best solution. I can't believe leaving out that comparison could ever cause any problems. (on the other hand I totally understand why you might add some sort of if check for validation, I just think in this case it cause more problems than it helps)

Link to post
Share on other sites

then delete it if you don't want to use it.

 

Its there as in the beginning threads were running wild on their own, and there wasn't to much in way of control.  you might set it to X number times to loop, but it was going past that, or not completing properly.

 

If it was more stable I would have removed it a while ago.  but if you have no problems with it in there or out, feel free to adjust it as you need..

Link to post
Share on other sites

I understand, thank you!
(in the main post, in the comparison you can simply change < to <= and it will create the last account too)

 

All the best,

Marton

Link to post
Share on other sites

Hi TJ!

 

Could please explain something to me in the following code...?

 

with reference to what  @Dutch posted here - http://www.ubotstudio.com/forum/index.php?/topic/10042-new-v4-tutorial-multi-threading-example/page-2&do=findComment&comment=73972

ui drop down("Thread Count", "2,3,4,5,6,7,8,9,10", #num threads)
ui text box("Number of accounts", #number accounts)
set(#num created, 0, "Global")
set(#used threads, 0, "Global")
loop(#number accounts) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
}
define loop process {
    increment(#used threads)
    increment(#num created)
    registration procedure()
}
define registration procedure {
    thread {
        in new browser {
            registration code here()
            decrement(#used threads)
        }
    }
}
define registration code here {
    if($comparison(#num created, "<", #number accounts)) {
        then {
            reset account("Any")
            set(#user, $account data("Username"), "Local")
            set(#pass, $account data("Password"), "Local")
            wordpress()
            myopera()
        }
        else {
        }
    }
}
define wordpress {
    navigate("https://signup.wordpress.com/signup/", "Wait")
    type text(<username field>, #user, "Standard")
    type text(<password field>, #pass, "Standard")
    wait(30)
}
define myopera {
    navigate("https://my.opera.com/community/signup/", "Wait")
    type text(<username field>, #user, "Standard")
    type text(<password field>, #pass, "Standard")
    wait(30)
}

In 'define registration code here' you are setting #user and #pass variables to local - so how can they be used by  the 'wordpress' and 'myopera' commands ? As local variables cannot be passed outside the command / function using it?

 

Sorry if this sounds stupid.. I am just trying to understand multithreading...

 

 

 

--

also - in

 

define code procedure {
if($comparison(#completed rows, "<", $list total(%List1))) {
then {

 

we are not setting  '#completed rows' to anything initially , nor are we declaring it via the set command. is this ok to do?

 

Thanks. :)

Link to post
Share on other sites
  • 3 months later...

--

also - in

 

define code procedure {

if($comparison(#completed rows, "<", $list total(%List1))) {

then {

 

we are not setting  '#completed rows' to anything initially , nor are we declaring it via the set command. is this ok to do?

 

Thanks. :)

The same question here, is that variable necessary? 

Link to post
Share on other sites
  • 2 months later...

with change proxy node inside that in new browser.

 

it will work locally when used inside a thread.

 

 

add list to list, list from file

at the very beginning before threading

 

then call change proxy, next list item

inside the in new browser

Link to post
Share on other sites
  • 4 weeks later...

Please help me, what if the #number accounts = total %success create account
This is still an error, the bot can not stop

ui drop down("Thread Count", "2,3,4,5,6,7,8,9,10", #num threads)
ui text box("Number of accounts", #number accounts)
navigate("http://ubotstudio.com/playground/simple-form", "Wait")
wait for element(<about me textarea>, "", "Appear")
set(#succes blog check, $false, "Global")
set(#used threads, 0, "Global")
set(#num created, 0, "Global")
clear list(%success create account)
loop while($comparison(#succes blog check, "=", $false)) {
    increment(#used threads)
    increment(#num created)
    reset account("Any")
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    thread {
        in shared browser {
            if($comparison(#num created, "<=", #number accounts)) {
                then {
                    account creation()
                }
                else {
                }
            }
            decrement(#used threads)
        }
    }
}
define account creation {
    navigate("http://ubotstudio.com/playground/simple-form", "Wait")
    wait for element(<about me textarea>, "", "Appear")
    reset account("Any")
    set(#user, $account data("Username"), "Global")
    type text(<username field>, #user, "Standard")
    set(#pass, $account data("Password"), "Global")
    type text(<password field>, #pass, "Standard")
    click(<value="Submit">, "Left Click", "No")
    wait for element(<id="global-footer">, 60, "Appear")
    if($exists(<innertext="Account Created">)) {
        then {
            add item to list(%success create account, "{#user}:{#pass}", "Delete", "Global")
        }
        else {
        }
    }
    if($comparison(#number accounts, "=", $list total(%success create account))) {
        then {
            set(#succes blog check, $true, "Global")
        }
        else {
        }
    }
}

sorry for my bad english, I hope you can understand
thanks!

Link to post
Share on other sites
  • 2 months later...
  • 3 weeks later...

 

Here's a Multi Threading Example that TJ helped me with that processes a list with 3 elements per row. I originally tried to use TJ's Advanced example using Tables but found that the multi threading was either missing rows entirely or doubling up on rows. 

 

This was primarily due to the fact that the table row value was incremented at the end of each cycle and is a global setting not a local setting. This allowed multiple threads to attempt to increment the table row value at the same time and resulted in almost certain misses in the processing.

 

Following is a complete example for Multi Threading  using lists with multiple elements per row. Thanks again to TJ for his help!

MultiThreading Using Lists

sourcedata.csv
A,26,z
B,25,y
C,24,x
D,23,w
E,22,v
F,21,u
G,20,t
H,19,s
I,18,r
J,17,q
K,16,p
L,15,o
M,14,n
N,13,m
O,12,l
P,11,k
Q,10,j
R,9,i
S,8,h
T,7,g
U,6,f
V,5,e
W,4,d
X,3,c
Y,2,b
Z,1,a

set user agent("Chrome")
Create Lists()
set(#num threads, 2, "Global")
set(#used threads, 0, "Global")
loop($list total(%List1)) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
}
define loop process {
    increment(#used threads)
    run procedure()
}
define run procedure {
    thread {
        in new browser {
            code procedure()
            decrement(#used threads)
        }
    }
}
define code procedure {
    if($comparison(#completed rows, "<", $list total(%List1))) {
        then {
            comment("NO NEED TO CLEAR IT
THE THREAD EXITS IT CLEARS ON AUTO")
            add list to list(%local break down, $list from text($next list item(%List1), ","), "Don\'t Delete", "Local")
            set(#VariableA, $list item(%local break down, 0), "Local")
            set(#VariableB, $list item(%local break down, 1), "Local")
            set(#VariableC, $list item(%local break down, 2), "Local")
            comment("START REST OF YOUR CODE RIGHT IN HERE
THE VARIABLES ABOVE WONT SHOW
IN YOUR DEBUGGER< SAME WITH THE 
BREAK DOWN LIST -- THEY ARE LOCAL")
            add item to list(%recompile, "{#VariableB},{#VariableC},{#VariableA}", "Don\'t Delete", "Global")
        }
        else {
        }
    }
    increment(#completed rows)
}
define Create Lists {
    set(#Source, "{$special folder("Desktop")}\\Ubot\\UbotData\\", "Global")
    clear list(%List1)
    clear list(%recompile)
    add list to list(%List1, $list from file("{#Source}sourcedata.csv"), "Don\'t Delete", "Global")
    set list position(%List1, 0)
}

 

What did you set #completed rows to? And why do you have that if($comparison... bit at the end? What are variables A, B and C for? If you get rid of that bit of code, would the loop process still work correctly?

 

Need help figuring out how to do this but with a table instead of a list, so I'm looking to set a #row variable and make it increment that after completing a loop, but it won't work. Help, please!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...