Need a better way to pause a thread

Marc mnations at airmail.net
Tue Jul 23 18:56:53 EDT 2002


Hi:

I am trying to find the best way to pause one of my threads. In most
areas where the modules are small or in loops, I have an event created
that I just event.wait() for. This works very well. However, in
another area of code I have a long series of unique commands. I want
to avoid having to place event.wait() dozens of times. I tried the
following:


def check():

    print "in check"

    globals.pause.wait()

    if globals.stop.isSet():

        globals.status.clear()

        globals.stop.clear()

    globals.master.after(100, check)
 

I was hoping that by continually checking this loop it would pause the
thread when it hit the ...pause.wait() command. However, it just seems
to hang. I guess because the after() command for this function is not
sequentially tied to the rest of the code, and the rest of code keeps
going while this command gets confused.


Either way, under Windows with Python there's no way to create a
thread and just pause execution of the thread from an os level. So is
there a better way to be able to pause a long series of unique
commands without having to sprinkle holds everywhere?


Thanks ahead of time,
Marc



More information about the Python-list mailing list