Jump to content
UBot Underground

[Sell] Smart Thread Plugin - Easy threading


Recommended Posts

  • Replies 185
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi James.   I converted the example from the thread you posted. I also removed some of the stuff that was in the script that is not directly required to get the job done:   So here's the ThreadPlugin

So in general. With multithreading there are a couple of things you should be aware of.   1. Threads are running at the same time. So you can't use global variables to store data.  2. Add data to a gl

Duplicate post. I replied in the ExBrowser Thread.   Dan

It's to help organise code more than anything.

I converted an existing bot with multiple defines that helped modularize code into separate functional blocks of code.

Converting to a multi-thread version means I have to either bring all the code back into a single define (Will make the define about 600 lines ... and reminds me of when I had to write COBOL programs many moons ago) or make each separate define accept and return lots of different parameters.

Link to post
Share on other sites
set(#Local, $random text(20), "Local")
plugin command("Bigtable.dll", "Create Large Table", "singlevar{#Local}", 1, 1)
comment("you can now read and write to the single cell table")
comment("write")
plugin command("Bigtable.dll", "Set Large Table cell", "singlevar{#Local}", 0, 0, "test")
comment("read")
alert($plugin function("Bigtable.dll", "Large Table Cell", "singlevar{#Local}", 0, 0))

try the local dictionary plugin it may work if not create.

if not use the largedata plugin and use the table to create artificial local vars example attached.

 

what this is basically doing is creating a local single cell table which you can use throughout the thread.

not the most elegant way of doing things but will work for what your trying to achieve.

 

don't forget to clear the table when your done to reduce memory.

 

you could also use just one table for storing all your local vars just add additional rows.

  • Like 1
Link to post
Share on other sites

Fantastic plugin. So much simple, and now much easier to have threads inside threads. :)

 

I love the Stop feature. Just one a question, are you able to stop/close a single thread? because the Smart thread stop stops them all.

Example:

 

else {

plugin command("LocalDictionary.dll", "local dictionary add", "Account_Cap_Max", #ui_Accounts_Cap)

plugin command("LocalDictionary.dll", "local dictionary add", "Account_Cap_Max_Left", 0)

Set Thread Status("Captcha Failed. This account has exceeded the maximum Captcha Retries.")

comment("I then want it to close the thread (Like it's finished) and go to the next list item.")

}

I found a "eh" way to do that. Have a "IF" command on every major part to check if that local var is set to, say "True". If it's true, it just skips the whole commands all the way to the end of the threading script. Which then the smart thread closes the thread and opens a new one with the new local list item. Just wanted to see if there was a more simpler way of doing it or if you could plan a update with that feature. :)

 

Regards,

HaHaItsJake

Link to post
Share on other sites

that's not possible with the plugin, stop is designed to stop all. Quick question thou what are you trying to achieve single thread stop from inside the thread?

 

Should have been more clear about why it would be useful to not just me, but others too.

 

Say, I have a multi-threaded account creator bot. The account page has a captcha on it. you set the Max Captcha to 3, and one thread fails all 3 times. You don't want it to keep going with the same account details so you want to classify it as a failed account for that single thread and have it move to the next account name. Doing so, it would stop the threads from 1/4 completing that thread, close it and open it. 

 

I currently have a "Captcha Check".  If the Max Captcha number is hit, it sets Cap_Fail to True. Once it's true, the "fill text fields() is the define I want to run after the captcha fail. Since it's true, it will pass the commands, skip them all the way back to the thread beginning with Smart Thread to start a new threads, and close the Cap_Fail thread.

 

 
Code below is set to "Stop" button without the smart thread stop. (Same system as Cap_Fail just less complicated for a example tonight)
ui button("Start") {
    Start()
}
ui button("Stop") {
    set(#Stop, $true, "Global")
}
ui drop down("Accounts:", "1,2,3,4,5,10,20,30,40", #ui_Accounts_Num)
ui drop down("Threads:", "1,2,3,4,5,10,15,20", #ui_Threads)
define Start {
    set(#Stop, $false, "Global")
    plugin command("Smartthreads.dll", "Threadcontrol Advanced initial", #ui_Threads)
    plugin command("Smartthreads.dll", "Thread control Advanced add", "Starting_Start", "Loop Number", #ui_Accounts_Num, "No")
    plugin command("Smartthreads.dll", "Thread control Advanced finish wait")
    add list to table as column(&Account_Created, 0, 0, %Account_Created)
    alert("Complete!")
}
define Starting_Start(#Row) {
    set(#Stop, $false, "Global")
    wait(1)
    alert("{#Row}

Please Press Stop Now.")
    if($comparison(#Stop, "!=", $true)) {
        then {
            in new browser {
                if($comparison(#Stop, "!=", $true)) {
                    then {
                        wait(3)
                        wait(3)
                    }
                }
                wait(3)
                if($comparison(#Stop, "!=", $true)) {
                    then {
                        alert("{#Row}
Finished by self")
                    }
                    else {
                        alert("{#Row}
Finished by you stopping it.")
                    }
                }
            }
        }
    }
}

Same sample, just click "Stop" after the alert. Threads (2) Account s(4-6) and you'll see what I mean. After clicking Ok on the first alert "Please Press Stop Now". 

 

Same method will work, just local wit the Cap_Retires. 

 

Regards,

HaHaItsJake

 

 

PS: if this isn't clear, I'll create the complicated Cap_Fail tomorrow.

Link to post
Share on other sites

Advise welcome....

 

I'm using the Smart Thread plugin and it's working great. In fact ... too good !

I'm calling an API service and after implementing multi-threading with the Smart-Thread plugin there are times when a thread calls the API too fast and the server replies with a 'Slow Down' message.

 

I don't want to reduce the number of threads being used but instead introduce a bit of logic to make each thread check that it doesn't execute the API call within 50 milliseconds (I'll use javascript to give me milliseconds) of any other thread calling the same API.

 

What would you recommend I use to hold the TIME the API was last called by any thread so I can compare it against the current time.. A large table cell, something else or implement a different type of delay function?

 

I want to make sure what every I use to hold the value isn't going to be affected by another thread until the comparison is done.

Link to post
Share on other sites

Advise welcome....

 

I'm using the Smart Thread plugin and it's working great. In fact ... too good !

I'm calling an API service and after implementing multi-threading with the Smart-Thread plugin there are times when a thread calls the API too fast and the server replies with a 'Slow Down' message.

 

I don't want to reduce the number of threads being used but instead introduce a bit of logic to make each thread check that it doesn't execute the API call within 50 milliseconds (I'll use javascript to give me milliseconds) of any other thread calling the same API.

 

What would you recommend I use to hold the TIME the API was last called by any thread so I can compare it against the current time.. A large table cell, something else or implement a different type of delay function?

 

I want to make sure what every I use to hold the value isn't going to be affected by another thread until the comparison is done.

 

Why not use a 

Loop while contains 'Slow Down'

wait (0.05)

 

 

One thing you have to decide is, if multithreading really helps here? If the web service has a limitation how often you can call it, threading might be overkill?

Or are your threads doing a lot of stuff afterwards so that each thread runs for a longer period of time?

 

Dan

Link to post
Share on other sites

Each thread does something like this...

 

calls API-1 which can return up to 20 records.

loop through each of the 20 records

  call API-2

  do a lot of processing

  call API-3

  do a lot of processing

end-loop
 
API-1 is where the issue is. If the API returns zero records the thread closes and another one starts. This can happen very fast and is what is causing the issue.
 
I know a global SLOW-DOWN variable of some kind is needed but I'm not sure of the best vehicle (Large table cell, global variable etc..) to hold the SLOW-DOWN value so that all threads do not step on each others toes and set/reset the value independently.
Link to post
Share on other sites

 

Each thread does something like this...

 

calls API-1 which can return up to 20 records.

loop through each of the 20 records

  call API-2

  do a lot of processing

  call API-3

  do a lot of processing

end-loop
 
API-1 is where the issue is. If the API returns zero records the thread closes and another one starts. This can happen very fast and is what is causing the issue.
 
I know a global SLOW-DOWN variable of some kind is needed but I'm not sure of the best vehicle (Large table cell, global variable etc..) to hold the SLOW-DOWN value so that all threads do not step on each others toes and set/reset the value independently.

 

 

You could check the API return value. And if it's empty, than add a wait command?

 

Dan

Link to post
Share on other sites
plugin command("Smartthreads.dll", "Threadcontrol Advanced initial", 10)
loop($list total(%yourfirstlist)) {
    comment("replace your code here with what ever your api request is")
    set(#results,$plugin function("HTTP post.dll", "$http get", $list item(%yourfirstlist,#mainloop), "", "", "", ""),"Global")
    comment("check if results return value")
    if($comparison(#results,"!=",$nothing)) {
        then {
            comment("add your code here for however you grab the details from the returned data")
            clear list(%second)
            add list to list(%second,$list from text(#results,$new line),"Delete","Global")
            comment("*********************")
            comment("pass that data into threads")
            plugin command("Smartthreads.dll", "Thread control Advanced add", "secondprocesspart", "List", %second, "No")
        }
        else {
            comment("your wait time required between api requests")
            wait(0.5)
        }
    }
}
plugin command("Smartthreads.dll", "Thread control Advanced finish wait")
define secondprocesspart(#row, #listitem) {
    comment("add the rest of your process here")
}

to add to dans comments if you still want threads for the rest of your process after the first api call you can do the following maybe.

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

Little Idea:

If you are looking for a way to update a stat monitor with the progress of your threads, there are multiple ways of doing that. 
I tried it with an additional thread first. I then had a counter which updated the statmon every 5 threads... That all worked, but it was more complicated than the idea I just had :-)

So I though I'll share it with you guys.

Here's my latest proxy tester script:

define TestProxyServers {
    plugin command("Smartthreads.dll""Threadcontrol Advanced initial", 10)
    plugin command("Smartthreads.dll""Thread control Advanced add""TestProxyThread""List"$plugin function("Bigtable.dll""Large list return""proxylistuntested"), "No")
    loop while($comparison($plugin function("Smartthreads.dll""Thread control Items Processed"),"<",$plugin function("Bigtable.dll""Large list total""proxylistuntested"))) {
        set(#proxystatus,"Testing.. {$plugin function("Smartthreads.dll""Thread control Items Processed")} von {$plugin function("Bigtable.dll""Large list total""proxylistuntested")}","Global")
        wait(0.1)
    }
    plugin command("Smartthreads.dll""Thread control Advanced finish wait")
    set(#proxystatus,$plugin function("Bigtable.dll""Large list total""proxychecked"),"Global")
}
define TestProxyThread(#counter) {
    if($plugin function("HTTP post.dll""$proxy checker"$plugin function("Bigtable.dll""Large list item""proxylistuntested"#counter), 10, "http://www.google.com")) {
        then {
            plugin command("Bigtable.dll""Add item to large list""proxychecked"$plugin function("Bigtable.dll""Large list item""proxylistuntested"#counter))
        }
    }
}
 

The advanced add will directly continue. And the loop while will then update the statmon. Then advanced finish wait will wait until all threads are really finished. 

Hope it helps.

Cheers

Dan

 

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

Is there anyway to manage two variables like #row in mulithread?

I mean im having troubles with them. My script is like:

In multithread:

{Do first job, get something from list1 using variable #row1.

If good then do second job, get something from list2 using variable #row2.

else do nothing}

The problem is if it fail, the variable #row2 will increase like #row1 when the thread exit if i use the variable #row for both of them and i cant think a way to let each threads take each turn in "get something from list2 using variable #row2" in case some of first job might fail (which mean the thread will have to exit to increase #row1).

Summary: Each items of list2 need to be done in the condition if first job get good result, else only increase the #row of list1 not list2.

Anyway kev123, can u help me with this?

Link to post
Share on other sites

Is there anyway to manage two variables like #row in mulithread?

I mean im having troubles with them. My script is like:

In multithread:

{Do first job, get something from list1 using variable #row1.

If good then do second job, get something from list2 using variable #row2.

else do nothing}

The problem is if it fail, the variable #row2 will increase like #row1 when the thread exit if i use the variable #row for both of them and i cant think a way to let each threads take each turn in "get something from list2 using variable #row2" in case some of first job might fail (which mean the thread will have to exit to increase #row1).

Summary: Each items of list2 need to be done in the condition if first job get good result, else only increase the #row of list1 not list2.

Anyway kev123, can u help me with this?

I believe what you're wanting to do is impossible with this plugin at the moment.

 

You'll need to use a strategy outside the plugin. $next list item would help with that. You can not advance a list postion from within the plugin. There's no command, but you can set loop number and use next list item which is thread safe.

 

Regards,

HaHaItsJake

  • Like 1
Link to post
Share on other sites

I believe what you're wanting to do is impossible with this plugin at the moment.

 

You'll need to use a strategy outside the plugin. $next list item would help with that. You can not advance a list postion from within the plugin. There's no command, but you can set loop number and use next list item which is thread safe.

 

Regards,

HaHaItsJake

U saved me this time Jake. Thanks a lot for ur advice. I tried and it worked like miracle :D.

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

does local dictionary work with this? 

does the thread counting work perfectly? even when using 20+ threads? 

1. Yes, but it's not required anymore in my oppinion. 

2. Yes as well.

 

 

But... Ubot 5.5.11 has a bug at the moment with threading. That was introduced with version 5.5.6

http://tracker.ubotstudio.com/issues/559

 

Dan

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

Hey Kev123, I am interested in buying your smartthread plugin, I tried your paypal link but it don t seem to work for me anyway. Please pm me so we can arrange some form of payment I can send you. Thanks.

Edited by denrich
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...