Jump to content

Thread not dying after restart


ryank645

Recommended Posts

currently having an issue during world hopping where the log produces the following error:

"Script executor is taking too long to suspend; restarting now..."

however, the previous thread does not die and the script will seem to multi-thread with the previous thread and the new thread, this happens repeatedly until multiple threads are running consecutively all trying to do the same thing.

this is the snippet where the issue arises:

 

do {
    m.log("Hopping");
    m.getWorlds().hopToP2PWorld();
    m.sleep(15000);
} while (m.myPlayer().exists() && player == null);

any help would be appreciated and any further logs or code will be provided if needed.

 

 

 

Edited by ryank645
Link to comment
Share on other sites

15 minutes ago, ryank645 said:

the problem persists even without the do while loop, although not as may threads are created. the snippet is trying to hop every 15 seconds until a certain player is found, player being a variable. the while myPlayer().isVisible is to stop execution when logged out for hopping too may times

Why are you multi threading?

You should place your conditions in if-statements, something like this

if(player == null && myPlayer.isVisible){
  //Hop
}

 

Edited by Hybris
Link to comment
Share on other sites

i had the if-statement previously before the do loop, the issue was still there however i have reverted the changes.

i don't know multiple threads are being created that's my problem. the script produces the error "Script executor is taking too long to suspend; restarting now..."  but doesn't kill the old thread so they both run at the same time. is there any way to check the number of threads running and kill them? if not then how do i prevent this error.

Edited by ryank645
Link to comment
Share on other sites

 

Make sure u use the script skeleton, if you put the if statement in the onLoop there shouldn't be a problem as far as I know.
You also need to make sure the script is sleeping while you're trying to log, otherwise it'll loop & you'll get multiple tries.

You can use conditional sleeps so it'll make sure you are hopped before waking up again.

https://osbot.org/forum/topic/127193-conditional-sleep-with-lambda-expressions/

 

If it still doesn't work, post the code you have & I'll take a look at it.

 

Edited by Hybris
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...