thread lock question
Ritesh Raj Sarraf
rrs at researchut.com
Wed Oct 11 09:09:32 EDT 2006
Hi,
I have a question regarding locks in threads.
Following is the code example:
if download_file(foo, bar) == True:
if some condition:
do_something()
if zip_bool:
ziplock.acquire()
try:
compress_the_file(zip_type_file, foo, bar)
os.unlink(foo) # Unlink it once it has been zipped
finally:
ziplock.release()
if zip_bool:
ziplock.acquire()
try:
compress_the_file(zip_type_file, foo, bar)
os.unlink(foo)
finally:
ziplock.release()
Basically, I'm testing for some condition, if that is True, do something and
then do the zipping. I'm also doing the zipping even if that's not true.
My question is, in a code example like this which is threaded, does the locking
mechanism work correctly ?
Or are two different locks being acquired ?
Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
"Stealing logic from one person is plagiarism, stealing from many is research."
"The great are those who achieve the impossible, the petty are those who
cannot - rrs"
More information about the Python-list
mailing list