
April 3rd, 2004, 09:26 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 18
Time spent in forums: 8 h 53 m 27 sec
Reputation Power: 0
|
|
Python Loops...
Hello all..
I'm writing a script for xChat with Python. Currently, there is a loop I am creating that needs to happen every X seconds, and for the commands in that loop to happen in between. Not only that, but the other parts of the script have to also respond as triggered by the text in the channel. Here is what I have for the loop:
(assuming the variables are set correctly, listTime is set @ 60, and fileTime is set @ 120)
Code:
def mainLoop():
global listTime
global fileTime
global xPyGetPower
listTimer = listTime
fileTimer = fileTime
while xPyGetPower == 'on':
if requestLists == 'on':
if listAvailable:
if listTimer == 1:
request_list()
listTimer = listTime
else:
listTimer = listTimer-1
if requestFiles == 'on':
if fileAvailable:
if fileTimer == 1:
request_file()
fileTimer = fileTime
else:
fileTimer = fileTimer-1
sleep(2)
Here's the problem. I fire the baby up, and it just sits there. Oh it loads the script, but I can't do anything else, and the rest of the script doesn't respond.
So how do I create a timed loop (every 2 seconds) that allows for the rest of the script to run at the same time (i'm assuming this is multithreading?) and doesn't lock up the program?!?
Any help would be appreciated!
Last edited by Johnny5ive : April 3rd, 2004 at 09:28 AM.
|