[Tutor] Locking a specific variable
Tino Dai
tinoloc at gmail.com
Sun Apr 23 17:55:16 CEST 2006
Hi there,
I am wondering if you could lock a specific variable with thread
locking. Let me illustrate:
def ftpQueuePut(filename="")::
if len(filename) > 0:
try:
fileQueue.put(filename,True,1) #Variable that I would like to
lock
except Queue.full:
print "Queue is full"
else:
pass
def ftpQueueGet():
try:
filename=fileQueue.get(True,1) #Variable that I would like to
lock
return filename
except Queue.Empty:
pass
Presently, the only way that I can see to do this using Python is to combine
the two functions into one and lock and unlock the entire thing . That
doesn't seem efficient and/or elegant to me. Any pointers about this?
-Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060423/60b520fe/attachment.htm
More information about the Tutor
mailing list