[Python-bugs-list] [ python-Bugs-456024 ] event synchronization
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 27 Aug 2001 22:56:05 -0700
Bugs item #456024, was opened at 2001-08-27 22:56
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456024&group_id=5470
Category: Threads
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: event synchronization
Initial Comment:
It would be nice if the set and clear operations
on Event objects atomically returned the old state of
the internal flag:
old_state = event.set()
if old_state: nevermind()
else: do_stuff ()
sets the flag to true and returns true if the flag
was already set, otherwise returns false.
This avoids the obvious race condition in
if event.isSet(): nevermind()
else:
event.set()
do_stuff()
Maybe there's a way to accomplish this with
Semaphore objects (I haven't figured this thread
stuff out yet) but the event interface is more
natural for some purposes (i.e. the event represents
a lock on a resource).
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456024&group_id=5470