[Tutor] thread locks

Rick Pasotto rick@niof.net
Mon, 3 Dec 2001 16:39:38 -0500

If the first thing I do in a long running function is to acquire a
lock, can I be guaranteed that the first statement after lauching
that function as a thread can accurately check for the existence
of the lock?

include thread,time
mutex = thread.allocate_lock()
def func():
	# do lots of stuff

while 1:
	if mutex.locked():
# thread has finished so I can do other things

I know this seems to defeat the purpose of using a thread but this is
in a Tkinter program and if I don't do this the main window will not
get redrawn if the user covers it up, etc.

Or is there a better way to solve my problem?

To tamper with man's freedom is not only to injure him, to degrade
him; it is to change his nature, to render him, in so far as such
oppression is exercised, incapable of improvement; it is to strip
him of his resemblance to the Creator, to stifle within him the
noble breath of life with which he was endowed at his creation.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net