Bot-Factory 602 Posted May 21, 2014 Report Share Posted May 21, 2014 I know it works...but I don't think that's efficient, since UI always needs to execute function that way vs. only reading variable (and I think that happens pretty often since UI is constantly updated)...Good point though :-) Quote Link to post Share on other sites
UBotDev 276 Posted May 21, 2014 Author Report Share Posted May 21, 2014 Good point though :-)Yeah, I don't think it's a good practice, so I always avoid that and always use variables there... Quote Link to post Share on other sites
luis carlos 94 Posted May 21, 2014 Report Share Posted May 21, 2014 Thanks, my code is this: ui drop down("Threads", "5,10,20,30,40,50", #INPUT Threads) ui stat monitor("Threads (Active/Total):", "<b>{#THREADS Active}/{#THREADS Max}</b>") comment("Total de la lista que va a ser navegada.") ui stat monitor("COUNT:", #COUNT) set(#THREADS Max, #INPUT Threads, "Global") clear list(%PROXIES) add list to list(%PROXIES, $list from text("http://alice.pandorabots.com/ http://botbench.com/ http://botpoet.com/ http://commons.wikimedia.org/wiki/User:Flickr_upload_bot http://dictionary.reference.com/browse/bot http://egg-bot.com/ http://en.wikipedia.org/wiki/Ben_Bot http://en.wikipedia.org/wiki/Boe-Bot http://en.wikipedia.org/wiki/Bot http://en.wikipedia.org/wiki/Bot,_Tarragona http://en.wikipedia.org/wiki/Bot_Colony http://en.wikipedia.org/wiki/Bot_herder http://en.wikipedia.org/wiki/Botfly http://en.wikipedia.org/wiki/Botnet http://en.wikipedia.org/wiki/Bots http://en.wikipedia.org/wiki/Build%E2%80%93operate%E2%80%93transfer http://en.wikipedia.org/wiki/Chatterbot http://en.wikipedia.org/wiki/Computer_poker_players http://en.wikipedia.org/wiki/Googlebot", $new line), "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 { } } set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global") 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) increment(#PROXIES ROW) decrement(#COUNT) } else { wait(0.2) } } } define THREAD START(#PROXIES ROW) { thread { in shared browser { SCRAPE WHATSMYIP(#PROXIES ROW) } set(#THREADS Active, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global") } } 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) } stop script define SCRAPE WHATSMYIP(#PROXIES ROW) { navigate($list item(%PROXIES, #PROXIES ROW), "Wait") wait(20) } And a short video about the problem is http://www.screencast.com/t/yTKKBPdyfXAre you sure that's all you changed? Please share your code, else it's almost impossible to help you. Quote Link to post Share on other sites
UBotDev 276 Posted May 21, 2014 Author Report Share Posted May 21, 2014 Interesting...I've never noticed that but it looks like threading doesn't work with "shared browser" (I've never used it since I don't think it's a good idea...1 login+multiple threads). Although "$list item" returns the correct value navigate command just won't obey that and it will navigate to the page that started loading first (ignoring all other navigate commands that execute almost simultaneously). However, if you really need it to work like that adding 1s delay after THREAD START() solved the problem here. 1 Quote Link to post Share on other sites
Bot-Factory 602 Posted May 21, 2014 Report Share Posted May 21, 2014 Hey there it is... my new friend.. the one second delay to fix threading  Sorry couldn't resist 1 Quote Link to post Share on other sites
UBotDev 276 Posted May 21, 2014 Author Report Share Posted May 21, 2014 Hey there it is... my new friend.. the one second delay to fix threading  Sorry couldn't resist I had you in mind when giving the suggestion...I knew you'll like the solution.  But really...couldn't find a better one (I think the problem is related to how shared browser works). Quote Link to post Share on other sites
luis carlos 94 Posted May 21, 2014 Report Share Posted May 21, 2014 Thanks guys, it worked! Quote Link to post Share on other sites
UBotDev 276 Posted October 13, 2014 Author Report Share Posted October 13, 2014 Finally this problem seems to have been fixed in UBot v5.5, so I think this plugin won't be required for people using v5.5 or greater versions. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted October 13, 2014 Report Share Posted October 13, 2014 Kewl Thanks for holding us over TC Quote Link to post Share on other sites
earthlingj 13 Posted December 7, 2014 Report Share Posted December 7, 2014 This doesn't seem to be working perfectly for me. Over time, the thread count goes off. for example i have 0 threads open now in which my bot should restart its function, but thread counter is on 1 so its stuck doing nothing. Quote Link to post Share on other sites
Bot-Factory 602 Posted December 7, 2014 Report Share Posted December 7, 2014 This doesn't seem to be working perfectly for me. Over time, the thread count goes off. for example i have 0 threads open now in which my bot should restart its function, but thread counter is on 1 so its stuck doing nothing. Hello.  I tried to guess and visualize a little bit.. But I'm very sorry... I wasn't able to see your code in front of my eye's I think it would be helpful if you give us some more details. Dan Quote Link to post Share on other sites
UBotDev 276 Posted December 7, 2014 Author Report Share Posted December 7, 2014 This doesn't seem to be working perfectly for me. Over time, the thread count goes off. for example i have 0 threads open now in which my bot should restart its function, but thread counter is on 1 so its stuck doing nothing.  Yeah, as Dan said, it's hard to help you without seeing any code... I didn't have any problems till now, so I'm not sure what could be wrong. Quote Link to post Share on other sites
earthlingj 13 Posted December 7, 2014 Report Share Posted December 7, 2014 plugin command("HTTP post.dll", "http clear objects") plugin command("LocalDictionary.dll", "clear global dictionary") loop(99999999) { Scrape Process() set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global") set(#Loops, $list total(%UniqueUsers), "Global") set(#ListItem, 0, "Global") loop(#Loops) { loop while($comparison(#ThreadCount, ">=", 10)) { wait(1) } set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global") thread { plugin command("LocalDictionary.dll", "init local dictionary") plugin command("LocalDictionary.dll", "local dictionary add", "Target", $list item(%UniqueUsers, #ListItem)) Login() set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global") } wait(1) increment(#ListItem) } loop while($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), ">", 0)) { wait(5) } } Quote Link to post Share on other sites
UBotDev 276 Posted December 7, 2014 Author Report Share Posted December 7, 2014 One know issue is that the script won't stop (although threads finished), so you need to put "stop" command at the end of the code. Also, FYI, you should pass variable #ListItem through a define command (the code you have inside thread should be in that command/function) to ensure it stays unchanged during the thread lifetime. Else that variable may change before it's used inside the thread, meaning that you would be passing wrong data in there.... Quote Link to post Share on other sites
earthlingj 13 Posted December 7, 2014 Report Share Posted December 7, 2014 adding a stop wont work for me, because what i am doing is scraping 25 pages. then threading the process of posting on them. then when thread is back to 0. scrape next 25 pages. then thread to post on them. etc etc.  plus, shouldnt thread count still be correct regardless? Quote Link to post Share on other sites
UBotDev 276 Posted December 7, 2014 Author Report Share Posted December 7, 2014 adding a stop wont work for me, because what i am doing is scraping 25 pages. then threading the process of posting on them. then when thread is back to 0. scrape next 25 pages. then thread to post on them. etc etc.  Then you are not experiencing that problem (I guess you didn't read that post...the problem is related to part when bot reaches the end of script but won't stop).You should still take that other suggestion into consideration... Yes, threads should drop to 0. I've stripped down your code a bit and threading itself works just fine (threads drop to 0 and alert is displayed), so I think you may have problems elsewhere.  Here is the code: loop(99999999) { set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global") set(#Loops, 101, "Global") set(#ListItem, 0, "Global") loop(#Loops) { loop while($comparison(#ThreadCount, ">=", 10)) { wait(0.1) } set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global") thread { set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global") } wait(0.1) increment(#ListItem) } loop while($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), ">", 0)) { wait(5) } alert("") } What value does variable #Loops have on your side - are you opening too many threads? Quote Link to post Share on other sites
earthlingj 13 Posted December 7, 2014 Report Share Posted December 7, 2014 Loops is the number of scraped posts ( usually between 20-30  )Then you are not experiencing that problem (I guess you didn't read that post...the problem is related to part when bot reaches the end of script but won't stop).You should still take that other suggestion into consideration... Yes, threads should drop to 0. I've stripped down your code a bit and threading itself works just fine (threads drop to 0 and alert is displayed), so I think you may have problems elsewhere.  Here is the code: loop(99999999) { set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global") set(#Loops, 101, "Global") set(#ListItem, 0, "Global") loop(#Loops) { loop while($comparison(#ThreadCount, ">=", 10)) { wait(0.1) } set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global") thread { set(#ThreadCount, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global") } wait(0.1) increment(#ListItem) } loop while($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), ">", 0)) { wait(5) } alert("") } What value does variable #Loops have on your side - are you opening too many threads? Quote Link to post Share on other sites
UBotDev 276 Posted December 7, 2014 Author Report Share Posted December 7, 2014 As you can see in this video, the code I've posted above works fine, that's why I think there is nothing wrong with threading...I guess it may be your code/setup. Does the code above work for you or not? What version of UBot are you using? Maybe you should share the whole code, since this part seems to work ok.... Quote Link to post Share on other sites
earthlingj 13 Posted December 8, 2014 Report Share Posted December 8, 2014 it works fine at the beginning but if you leave it running for a while ( after a few hours ) thats when the thread counter goes off  in one of my other bots, the thread counter sometimes even goes in the negative after a while.     also, as for passing the list item in a define? why that instead of local dictionary? I thought local dictionary is thread safe? Quote Link to post Share on other sites
UBotDev 276 Posted December 9, 2014 Author Report Share Posted December 9, 2014 I've been running bots with thread counter for days and I haven't noticed anything like that. I also left the code above running for some time an nothing. Whatever you use you need to use define command to ensure that value you pass in doesn't changes when a new thread is about to start. Local dictionary being thread safe has nothing to do with this.... Quote Link to post Share on other sites
earthlingj 13 Posted December 10, 2014 Report Share Posted December 10, 2014 I changed it to use define like you said and it makes no difference. After hours of running, the thread counter ends up being off still.  and the reason i said local dictionary is because you are sayuing define so that the value passed doesnt change, but local dictionary value shouldnt change either within the thread. Quote Link to post Share on other sites
UBotDev 276 Posted December 10, 2014 Author Report Share Posted December 10, 2014 Strange...I can't reproduce it so I can't do anything to help you.... Again, local dictionary has nothing to do with that....the problem is in UBot variable "#ListItem" that you are passing to thread, and that value can change for thread because you are not using define command. EDIT: If you still need confirmation about define commands, Dan wrote a post about that recently: http://www.ubotstudio.com/forum/index.php?/topic/17292-info-biggest-mistake-with-threading/ Quote Link to post Share on other sites
earthlingj 13 Posted December 10, 2014 Report Share Posted December 10, 2014 Its strange because i changed it to use defines and now after just 100 posts im at -2 threads and it stopped instead of continuing 1000s Quote Link to post Share on other sites
UBotDev 276 Posted December 11, 2014 Author Report Share Posted December 11, 2014 The only thing I see is that you should read thread count with plugin on problematic places, not by reading UBot variable...refering to this line of code (#ThreadCount doesn't have up to date info on threads count): loop while($comparison(#ThreadCount, ">=", 10)) { If threads go down to negative values I'm sure you are decrementing thread counter more often than you should (you haven't shared the whole code, so problem may be elsewhere). Without a way to reproduce the problem I can't really help you. Quote Link to post Share on other sites
earthlingj 13 Posted December 12, 2014 Report Share Posted December 12, 2014 Okay i changed it to use the thread counter read instead of by variable and its still miscounting. I changed my thread code to be exactly like your example as well with the only difference being my define command. the thread counts are all outside of my define so nothing within the define code should be messing up the thread counter.... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.