Jump to content



Photo

[FREE PLUGIN] Threads Counter - UBot v4 Threading Fixed

threading fixed counter v4

  • Please log in to reply
158 replies to this topic

#1 UBotDev

UBotDev

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1395 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 02:06 PM

As you may be aware threading in UBot v4 is not safe and may not work as expect under certain conditions, which would result in threads slowly dying out, so at the end, you only get left with 1 active thread, although you coded the bot to run with multiple (problem explained here). Threads Counter plugin was created to solve threading problems in UBot v4 by providing a dedicated Threads Counter to your UBot environment which allows you to implement threading properly.

 

"$threads counter" function allows you to perform 4 different operations, which can be seen on image bellow, and are quite self explanatory.

 

threads-counter-289x300.png

 

For more information about Threads Counter plugin please visit this page:

http://ubotdev.com/f...threads-counter

 

EXAMPLE: Scraper With Proxies and Multiple Threads

The code bellow will scrape some details about your proxy from "whatsmyip.com", with 1 proxy per thread. To test the code please copy paste it to UBots "code view", save it to a file, and save your proxies to "proxies.txt" file, which should be located in the same folder where you saved UBot file. After that you are ready to run the code. Read more: http://ubotdev.com/f...ultiple-threads

ui drop down("Threads", "10,20,30,40,50", #INPUT Threads)
ui stat monitor("Threads (Active/Total):", "<b>{#THREADS Active}/{#THREADS Max}</b>")
ui stat monitor("COUNT:", #COUNT)
set(#FOLDER Root, $special folder("Application"), "Global")
set(#THREADS Max, #INPUT Threads, "Global")
clear table(&RESULTS)
add list to table as row(&RESULTS, 0, 0, $list from text("Proxy Used,IP,Proxy,City,Country,ISP,STATUS", ","))
set(#RESULTS ROW, 1, "Global")
clear list(%PROXIES)
add list to list(%PROXIES, $list from file("{#FOLDER Root}\\proxies.txt"), "Delete", "Global")
set(#PROXIES ROW, 0, "Global")
set(#COUNT, $list total(%PROXIES), "Global")
if($comparison(#THREADS Max, ">", #COUNT)) {
    then {
        alert("You need to have more proxies than threads.")
        stop script
    }
    else {
    }
}
comment("Reset counter to 0.")
set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global")
comment("Main Threading Loop")
loop while($comparison(#COUNT, ">", 0)) {
    if($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), "<", #THREADS Max)) {
        then {
            comment("Increment Number Of Threads And Store Value to UBot Variable.")
            set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global")
            if($comparison(#PROXIES ROW, ">=", $list total(%PROXIES))) {
                then {
                    set(#PROXIES ROW, 0, "Global")
                }
                else {
                }
            }
            THREAD START(#PROXIES ROW, #RESULTS ROW)
            increment(#PROXIES ROW)
            increment(#RESULTS ROW)
            decrement(#COUNT)
        }
        else {
            wait(0.2)
        }
    }
}
comment("Thread Command")
define THREAD START(#PROXIES ROW, #RESULTS ROW) {
    thread {
        in new browser {
            CHANGE PROXY(#PROXIES ROW)
            SCRAPE WHATSMYIP(#PROXIES ROW, #RESULTS ROW)
        }
        set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global")
    }
}
comment("Wait For Threads To Close")
set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "read"), "Global")
loop while($comparison(#THREADS Active, ">", 0)) {
    set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "read"), "Global")
    wait(2)
}
save to file("{#FOLDER Root}\\results.csv", &RESULTS)
stop script
define CHANGE PROXY(#PROXIES ROW) {
    clear list(%PROXY)
    add list to list(%PROXY, $list from text($list item(%PROXIES, #PROXIES ROW), ":"), "Don\'t Delete", "Global")
    if($comparison($list total(%PROXY), "=", 4)) {
        then {
            set proxy credentials($list item(%PROXY, 2), $list item(%PROXY, 3))
            change proxy("{$list item(%PROXY, 0)}:{$list item(%PROXY, 1)}")
        }
        else if($comparison($list total(%PROXY), "=", 2)) {
            change proxy("{$list item(%PROXY, 0)}:{$list item(%PROXY, 1)}")
        }
        else {
            alert("Proxy on row #{#PROXIES ROW} is invalid.")
            stop script
        }
    }
}
define SCRAPE WHATSMYIP(#PROXIES ROW, #RESULTS ROW) {
    navigate("http://www.whatismyip.com/", "Wait")
    wait for browser event("DOM Ready", "")
    wait for element(<class="the-ip">, "", "Appear")
    if($exists(<class="the-ip">)) {
        then {
            set table cell(&RESULTS, #RESULTS ROW, 0, $list item(%PROXIES, #PROXIES ROW))
            set table cell(&RESULTS, #RESULTS ROW, 1, $scrape attribute(<class="the-ip">, "innertext"))
            set table cell(&RESULTS, #RESULTS ROW, 2, $scrape attribute(<class="the-proxy">, "innertext"))
            set table cell(&RESULTS, #RESULTS ROW, 3, $scrape attribute(<class="the-city">, "innertext"))
            set table cell(&RESULTS, #RESULTS ROW, 4, $scrape attribute(<class="the-country">, "innertext"))
            set table cell(&RESULTS, #RESULTS ROW, 5, $scrape attribute(<class="the-isp">, "innertext"))
            set table cell(&RESULTS, #RESULTS ROW, 6, "SUCCESS")
        }
        else {
            set table cell(&RESULTS, #RESULTS ROW, 6, "FAIL")
        }
    }
}

EXAMPLE: Threads Counter Unit Test

Please use example above (Scraper With Proxies and Multiple Threads) while it's easier to adopt for standard threading setup with UBot.

If you insist on using this code don't forget to replace "#COUNT" variable with you real count number and remove the timeout at the end, when waiting for all threads to close "$comparison(#WAIT Count, "<", 10".

ui drop down("COUNT", "100,1000,10000", #Input Count)
ui drop down("Threads", "10,20,30,40,50", #INPUT Threads)
ui stat monitor("Threads (Active/Total):", "<b>{#THREADS Active}/{#THREADS Max}</b>")
ui stat monitor("COUNT:", #COUNT)
set(#COUNT, #Input Count, "Global")
set(#THREADS Max, #INPUT Threads, "Global")
comment("Reset counter to 0.")
set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global")
comment("Main Threading Loop")
loop while($comparison(#COUNT, ">", 0)) {
    if($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), "<", #THREADS Max)) {
        then {
            comment("Increment Number Of Threads And Store Value to UBot Variable.")
            set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global")
            THREAD START()
            decrement(#COUNT)
        }
        else {
            wait(0.2)
        }
    }
}
comment("Thread Command")
define THREAD START {
    thread {
        comment("While This Is Only A Test We Only Delay Here.")
        wait(0.5)
        comment("Decrement Number Of Threads And Store Value to UBot Variable.")
        set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global")
    }
}
comment("Wait For Threads To Close Or Timeout After 20 seconds.")
set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "read"), "Global")
set(#WAIT Count, 0, "Global")
loop while($both($comparison(#THREADS Active, ">", 0), $comparison(#WAIT Count, "<", 10))) {
    set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "read"), "Global")
    increment(#WAIT Count)
    wait(2)
}
comment("Check How Many Threads UBot Sees.")
if($comparison(#THREADS Active, ">", 0)) {
    then {
        alert("Some threads were not closed/decremented properly.")
    }
    else {
        alert("All threads were closed")
    }
}

CLICK UBotDev.com - Download FREE UBot Plugins!

______________________________________________

 


#2 Steve

Steve

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 259 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 02:14 PM

Nice!!! I'm going to test this out shortly! Thanks!!



#3 Aymen

Aymen

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1361 posts
  • OS:Windows 8
  • Total Memory:4Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 02:58 PM

Great plugin bud!

keep up the good work!


★★★List Of Killer Ubot Plugins★★★

 

Need Support ? Submit a support ticket here

 

Refund Policy is Clear : No Refunds on all Ubot Plugins


#4 willywonka

willywonka

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 543 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 03:08 PM

Good work. Thanks for the plugin.



#5 Code Docta (Nick C.)

Code Docta (Nick C.)

    Member for Hire

  • Fellow UBotter
  • PipPipPip
  • 1340 posts
  • LocationIn a Python or UBot IDE or ubotdocta.com
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 18 November 2013 - 03:45 PM

Uber Kewl!!

 

Thanks a million, another dream come true.


UBot Expert Tutorials

 

ubot-docta-header-ubot-expert-store.png

 

UBot expert tutorials and documentation at ubotdocta.com


#6 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:06 PM

thx for this nice plugin
but i thing u also could solve the problem with the TinyMCE plugin which offer the "Thread safe Container" u can use that container inside a thread  everytime u do things 100% exclusiv

i havend test it yet with a counter but im sure that works well too



#7 kev123

kev123

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 735 posts
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:14 PM

thx for this nice plugin
but i thing u also could solve the problem with the TinyMCE plugin which offer the "Thread safe Container" u can use that container inside a thread  everytime u do things 100% exclusiv

i havend test it yet with a counter but im sure that works well too

yeah that worked pretty well good plugin until you increase to high threads. the problem is there is two issues the first is more than one thread accessing the variable and the second is ubot variables don't increment quick enough so even with a thread safe container sometimes the increment gets missed. tried this plugin solves the problem works well.



#8 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:19 PM

yeah that worked pretty well good plugin until you increase to high threads. the problem is there is two issues the first is more than one thread accessing the variable and the second is ubot variables don't increment quick enough so even with a thread safe container sometimes the increment gets missed. tried this plugin solves the problem works well.

Thread safe Container blocks access to vars lists tables as long the routine inside is running!
so if some another routine want have access to it have to wait untill is unlocked.
Systemwide Thread safe Container does this action Systemwide  means if u work same time with different bots on the same table/list and u have a save or read action  the container block access to all bots untill his job is done   condition is that lists and tables who needs that routin should name same... it works 100% i was use that many many times



#9 UBotDev

UBotDev

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1395 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:34 PM

thx for this nice plugin
but i thing u also could solve the problem with the TinyMCE plugin which offer the "Thread safe Container" u can use that container inside a thread  everytime u do things 100% exclusiv

i havend test it yet with a counter but im sure that works well too

As I have already mentioned that plugin doesn't work for me: http://www.ubotstudi...ge-2#entry86899


CLICK UBotDev.com - Download FREE UBot Plugins!

______________________________________________

 


#10 BeerNut

BeerNut

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 130 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:35 PM

Sorry I must be missing it but how do I download the plugin?



#11 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:40 PM

As I have already mentioned that plugin doesn't work for me: http://www.ubotstudi...ge-2#entry86899

dont know which version u use  but if u use the latest   u can set a memory free function in the 0.2sec else condition.
i saw a little mistake too if i use 10tsd and 50 threads but with the clear ubot memory option that will solve that too
 



#12 UBotDev

UBotDev

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1395 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:46 PM

Sorry I must be missing it but how do I download the plugin?

You will need to subscribe to my email list, and plugins will be sent to you right away.


CLICK UBotDev.com - Download FREE UBot Plugins!

______________________________________________

 


#13 UBotDev

UBotDev

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1395 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:48 PM

dont know which version u use  but if u use the latest   u can set a memory free function in the 0.2sec else condition.
i saw a little mistake too if i use 10tsd and 50 threads but with the clear ubot memory option that will solve that too

 

I used the version that was available at the time when I found the problem (1 month ago) but it didn't solve the problem as you can read on another post, where we already talked about that. In the video you can clearly see that I'm getting errors when executing that code.

 

Do we need to discuss it here again?

 

I'm not forcing anyone to use this plugin, I made it for my own needs and wanted to share it with the community. If that plugin works for you then use that one...


CLICK UBotDev.com - Download FREE UBot Plugins!

______________________________________________

 


#14 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 06:58 PM

I used the version that was available at the time when I found the problem (1 month ago) but it didn't solve the problem as you can read on another post, where we already discussed that. In the video you can clearly see that I'm getting errors when executing that code.

 

Do we need to discuss it here again?

Shame over me :)
i was trying to help.... i know what time it need to code a plugin so u got 100% my respect for give that the the folks for free
but i also knows that a plugin more needs more time to load ubot bots.
so if u dont like my solution i can lif with and sorry that noone knows about the new version...i only use it im not the broadcaster for that plugin so i realy dont know which release ppl are use.

 

and again i respect what u did i only was trying search for another solution that was my intension



#15 UBotDev

UBotDev

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 1395 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2013 - 07:09 PM

Shame over me :)
i was trying to help.... i know what time it need to code a plugin so u got 100% my respect for give that the the folks for free
but i also knows that a plugin more needs more time to load ubot bots.
so if u dont like my solution i can lif with and sorry that noone knows about the new version...i only use it im not the broadcaster for that plugin so i realy dont know which release ppl are use.

 

and again i respect what u did i only was trying search for another solution that was my intension

I appreciate that.

 

I also respect you and developer behind the plugin, but unfortunately there is no documentation and there is no support provided for that plugin (no one had time to explain what's going on with those errors?), which makes it hard or even impossible to use (like in my case where I wasn't able to get rid of those error popups).

 

Also, there was only 1 person who claimed that it's working at the time so I can't know if it's working or not based on that feedback, it's 1 vs 1, and I proved mine to work with the similar code.


CLICK UBotDev.com - Download FREE UBot Plugins!

______________________________________________

 


#16 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 07:51 PM

im totaly with u  belive me.... i would write a manual for, but my english is to bad for that.
i always try my best to explane some of the features but at the end it isnt my plugin, i only was the guy who wrotes some examples how to use some functions of it



#17 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 18 November 2013 - 07:52 PM

by the way with the free Ubot Memory function u can do lists with 1million lines  unbelivable :)



#18 Kreatus (Ubot Ninja)

Kreatus (Ubot Ninja)

    Custombotsolutions.com

  • Fellow UBotter
  • PipPipPip
  • 3081 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 18 November 2013 - 11:32 PM

by the way with the free Ubot Memory function u can do lists with 1million lines  unbelivable :)

What plugin is that blumi?

 

================

 

Thanks for this free plugin mate! :)



#19 zap

zap

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 866 posts
  • LocationUK london
  • OS:Windows 7
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 19 November 2013 - 01:52 AM

Awesome plugin UBotDev


  • zap likes this

#20 blumi40

blumi40

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 968 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 19 November 2013 - 04:03 AM

What plugin is that blumi?

 

================

 

Thanks for this free plugin mate! :)

http://ul.to/mmba1doj







Also tagged with one or more of these keywords: threading, fixed, counter, v4

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users