This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

doing two things at once....

Old posts that have not been replied to for several years.
Locked
t
tk421

doing two things at once....

Post by tk421 »

hi

i have a script can execute various commands when prompted to by channel commands. my problem is, is that some of these commands can take up to 30 secs to finish, and while the script is busy doing the command, it renders the bot inactive.

is there a way to maybe have the script execute a command in the background, and then still be able to reply to other requests it gets, even if it just queus them up. so as to make the bot look as if its still alive even if it is in the middle of executing a command.

hmm... hope somone can make sense of that :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is called multi-threading, and no it's not possible directly.

It's all dependant on what script needs what information.

If a script takes 30 seconds to complete, then you should look into reducing that time, as some of my high end script don't take that long.

1 method of doing what you want, is to split your script into 7 or 8 parts. At the end of each part, run a "utimer" for one second, to launch the second part and so on.

Noting again though, it's dependant on what information the script needs as to if this works or not.
t
tk421

Post by tk421 »

yea i figured as much, i think i can fit the timer solution in somehow. its not actually the script thats taking up the time, its actually an external process that the script executes.

thanks for the suggestion though
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

If it's an external program, then you can base it on what output it has give.

Insteadn of using the exec command, you can use the "open" command to create non-blocking access to the program. Using a a time, you can work out when the program has finished and close the handle.
t
tk421

Post by tk421 »

are you saying, use a timer (~30 secs) to guess when the program has finished? i can't tell how long for sure the execution may take, might only be a few secs. also i want to be able display a message when the execution is finished...

ta for the input
Locked