Jump to content
UBot Underground

UBot Freezing Running Define From Define From Define


Recommended Posts

Hello again, I have a problem I have a bot that is fairly large, with about 5 tabs each tab has it's own action like searching and following, and a different tab would be Searching and liking, I have taken the code in each tab and put it into define commands and then run a single UI from one tab hiding the rest of them, each tab also has error handling through out the code, and I have placed all the error handling in it's own tab and in define commands also to not clutter up the main code. So I end up running Define From Define From Define and now the bot just stops working after a while for no reason.

My question is how to stop the Freezing issue and am I running to many define commands, is it bad practice to build like this because of any know issues with running to many define commands in one bot.

Link to post
Share on other sites

I don't think you are having problems because of how many define commands, I think it's more where you call them from.

 

However, does the script ever completes/stops running? ...if it completes then it usually helps if you add short delays.

 

Maybe you should review how you call define commands from define commands, you need to make sure you don't have problems with recursion (calling 1st define from anywhere, then calling 2nd one from 1st one, which again calls 1st define, and you end up in infinite loop ), which usually freezes the the UBo

 

That's all I can say without any further info provided.

  • Like 1
Link to post
Share on other sites

I don't think you are having problems because of how many define commands, I think it's more where you call them from.

 

However, does the script ever completes/stops running? ...if it completes then it usually helps if you add short delays.

 

Maybe you should review how you call define commands from define commands, you need to make sure you don't have problems with recursion (calling 1st define from anywhere, then calling 2nd one from 1st one, which again calls 1st define, and you end up in infinite loop ), which usually freezes the the UBo

 

That's all I can say without any info provided.

 

It's wierd how it happens, I'm able to still intract with the page and click buttons and cheak boxes and the run button is still depressed, and when I hit stop the run button lights back up.

but the bot still stops at random times also, some times after 1000 likes and some time right after just 3 likes. It's like the bot just says, I had enough and I am done now and then stops for no reason that is visible to me.

Link to post
Share on other sites

Using defines is perfecto. There are alot of things to consider though. Always be sure that you are not using global variables throughout, as a define will alter your variables if they are global. Always think of a define as a suitcase. Try to keep as much as possible in the suitcase and pass variables in and out whenever possible. I know that ubot isn't 100% local variable friendly with tables, just lists and straight variables. But that's a biggie. Also, be sure that your code is clean. One reason to use defines is to also be able to test them one by one.

 

Finally, there is a small bug on return's and loop while command that I'm trying to hammer out with the dev's. That could lead to issues too.

 

If you want, I can scan your code privately and see if anything jumps out to me. Also take HelloInsomnia's advice, threads are good and they can also be very bad.

 

Cheers,

 

Frank

  • Like 1
Link to post
Share on other sites

Finally, there is a small bug on return's and loop while command that I'm trying to hammer out with the dev's. That could lead to issues too.

 

Frank?

 

Could you please let us know what those  bugs are which you have noticed..so we can be careful too.. in our coding.

 

Thanks.

Link to post
Share on other sites

 

Are you trying to run more than one thing at once? Are they in separate browsers or all trying to run in one because I could see how that would mess it all up.

 

Hello and thankyou for your replay, the bot is not mutiy threaded.

 

Using defines is perfecto. There are alot of things to consider though. Always be sure that you are not using global variables throughout, as a define will alter your variables if they are global. Always think of a define as a suitcase. Try to keep as much as possible in the suitcase and pass variables in and out whenever possible. I know that ubot isn't 100% local variable friendly with tables, just lists and straight variables. But that's a biggie. Also, be sure that your code is clean. One reason to use defines is to also be able to test them one by one.

 

Finally, there is a small bug on return's and loop while command that I'm trying to hammer out with the dev's. That could lead to issues too.

 

If you want, I can scan your code privately and see if anything jumps out to me. Also take HelloInsomnia's advice, threads are good and they can also be very bad.

 

Cheers,

 

Frank

 

Hello Frank This bug you mentioned may be the source of my problem, I am running lots of loop while placed through out my code.

Link to post
Share on other sites

You are right HelloInsomnia, I forgot to mention that. giganut, even if you don't use multiple threads you can't just run all of the tabs in the same browser at onc, since browser can only handle 1. If you are trying to run all at once, you should run each one "in new browser".

 

Frank, I'm also interesting what bug do you have in mind? I didn't have any problems with loop while or return.

Link to post
Share on other sites

You are right HelloInsomnia, I forgot to mention that. giganut, even if you don't use multiple threads you can't just run all of the tabs in the same browser at onc, since browser can only handle 1. If you are trying to run all at once, you should run each one "in new browser".

 

Frank, I'm also interesting what bug do you have in mind? I didn't have any problems with loop while or return.

 

Thank you for making that clearer for me, I am only running one at a time in the same browser. Like this, if Follow box checked then run follow define command, and if like box checked then run like define command.

Link to post
Share on other sites

So this means -

if -

tab01 -  contains my main program loop - let's say , I call all  functions and commands from here.

tab 02 - contains e.g- - function 01,function 02,command 01

tab 03 - contains  say - function 03,command 02

so.. this means if I am calling functions and commands from tab 01 -

then - in the 'default browser' or in 'new browser' - I cannot call both tab02 and tab 03 functions from within the same  browser ?

i.e -

in new browser

{

run function 01

run function 02

run function 03

run command 02

}

is not possible?

Please clarify. Thanks.

Link to post
Share on other sites

So this means -

if -

tab01 -  contains my main program loop - let's say , I call all  functions and commands from here.

tab 02 - contains e.g- - function 01,function 02,command 01

tab 03 - contains  say - function 03,command 02

so.. this means if I am calling functions and commands from tab 01 -

then - in the 'default browser' or in 'new browser' - I cannot call both tab02 and tab 03 functions from within the same  browser ?

i.e -

in new browser

{

run function 01

run function 02

run function 03

run command 02

}

is not possible?

Please clarify. Thanks.

You can run it that way: all functions will use the main browser (on after another).

 

But if you would add buttons to allow end user to run each function by clicking button for example, you would have to prevent 2 functions running at the same time/using the same browser.

Link to post
Share on other sites

I am afraid it is still not clear to me .. sorry for sounding dumb.. but let me understand what you said..

 

--> It is all right to run multiple functions located in multiple tabs in any browser - main or "in new browser" - as long as they run sequentially one after the other

 but in a multi threading scenario - you can have a situation where different functions from different tabs are running at the same time..so does that mean it cannot be used in multi threading?

 

thanks.

Link to post
Share on other sites

Sorry, maybe I wrote that to complex to understand.

 

Yes, as long as you run sequential you shouldn't worry about threads and new browsers.

 

If multiple functions are running at the same time (each in it's own thread) and they all require browser for operation, you need to open those function in new browsers, else they will all want to use the same browser, which just won't work (bot would fist navigate to URL from 1st function, and just a bit later it would navigate to 2ns function URL, so 1st function wouldn't be on the right page anymore). No, you can use multi threading anytime, you just need to implement it the right way.

 

Hope this explains it better.

Link to post
Share on other sites

Something that might help is changing all your loops to loop whiles. You have no control over loops, other than their final breakout condition, and with a loop while, you can have an either for each of your loops that ties to a single checkbox (running) true or false.

 

This will help you debug quicker, and give you a finer point of control.

Link to post
Share on other sites

Now that I have thought this through thoroughly, I believe that I am running more than one define command in the same browser at once. I will try to explain this the best I can. I will only use Tow tabs for an example, In tab one I have all of my code in a define command to run from the UI tab, All of the code in tab one has error handling placed throughout the code, all of the error handling code is being called from a different tab through a define command and in if statements throughout tab one, So if error happens then run the define command. Because the code that's in tab one is already in a define command, and the error handling that is placed throughout the code in tab one is placed in a define command also being called from a different tab. Then when the error handling is called, that would mean that the code is running tow define commands in the same browser at the same time.

 

If this is my problem then the bot is in big trouble, The reason that all of my error handling is placed in define command is because there is so much of it, and running it from tab one directly in the code makes the bot slow to a crawl and pretty much makes the bot worthless, If anyone has a solution to this problem please let me know. Here are some quick examples of what I am doing.

 

UI Tab

if($comparison(#Follow On Off, "=", $true)) {
    then {
        Reset All Vars Lists And Tables()
        Search And Follow()
    }
}

TAB ONE

define Search And Follow {
    comment("MORE CODE ABOVE")
    if($exists(<innertext="Failed to load data. Please reload your browser.">)) {
        then {
            Failed To Load Data Please Reload Your Browser one()
        }
    }
    comment("MORE CODE BELOW")
}
Link to post
Share on other sites

I was able to get all the error code back into the main code without any problems, and so far I have not been able to get the bot to freeze. Thanks for everyones help! I was running more than one define commands in the same browser at the same time, I was actualy trying to run more than that after taking a closer look.

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...