Re: Python 2.6's multiprocessing lock not working on second use?
- From: "Jesse Noller" <jnoller@xxxxxxxxx>
- Date: Mon, 19 Jan 2009 09:00:49 -0500
On Mon, Jan 19, 2009 at 8:16 AM, Frédéric Sagnes <speedup@xxxxxxxxx> wrote:
On Jan 19, 11:53 am, Frédéric Sagnes <spee...@xxxxxxxxx> wrote:
On Jan 17, 11:32 am, "Gabriel Genellina" <gagsl-...@xxxxxxxxxxxx>
wrote:
En Fri, 16 Jan 2009 14:41:21 -0200, escribiste en el grupo
gmane.comp.python.general
I ran a few tests on the new Python 2.6multiprocessingmodule before
migrating a threading code, and found out the locking code is not
working well. In this case, a pool of 5 processes is running, each
trying to get the lock and releasing it after waiting 0.2 seconds
(action is repeated twice). It looks like themultiprocessinglock
allows multiple locking after the second pass. Running the exact same
code with threads works correctly.
I've tested your code on Windows and I think the problem is on the Queue
class. If you replace the Queue with some print statements or write to a
log file, the sequence lock/release is OK.
You should file a bug report onhttp://bugs.python.org/
--
Gabriel Genellina
Thanks for your help gabriel, I just tested it without the queue and
it works! I'll file a bug about the queues.
Fred
For those interested, the code that works (well, it always did, but
this shows the real result):
class test_lock_process(object):
def __init__(self, lock):
self.lock = lock
self.read_lock()
def read_lock(self):
for i in xrange(5):
self.lock.acquire()
logging.info('Got lock')
time.sleep(.2)
logging.info('Released lock')
self.lock.release()
if __name__ == "__main__":
logging.basicConfig(format='[%(process)04d@%(relativeCreated)04d] %
(message)s', level=logging.DEBUG)
lock = Lock()
processes = []
for i in xrange(2):
processes.append(Process(target=test_lock_process, args=
(lock,)))
for t in processes:
t.start()
for t in processes:
t.join()
Opened issue #4999 [http://bugs.python.org/issue4999] on the matter,
referencing this thread.
Thanks, I've assigned it to myself. Hopefully I can get a fix put
together soonish, time permitting.
-jesse
.
- Follow-Ups:
- Re: Python 2.6's multiprocessing lock not working on second use?
- From: Nick Craig-Wood
- Re: Python 2.6's multiprocessing lock not working on second use?
- References:
- Python 2.6's multiprocessing lock not working on second use?
- From: Frédéric Sagnes
- Re: Python 2.6's multiprocessing lock not working on second use?
- From: Gabriel Genellina
- Re: Python 2.6's multiprocessing lock not working on second use?
- From: Frédéric Sagnes
- Re: Python 2.6's multiprocessing lock not working on second use?
- From: Frédéric Sagnes
- Python 2.6's multiprocessing lock not working on second use?
- Prev by Date: Python Style Guide Questions - Contd.
- Next by Date: Re: Overriding base class methods in the C API
- Previous by thread: Re: Python 2.6's multiprocessing lock not working on second use?
- Next by thread: Re: Python 2.6's multiprocessing lock not working on second use?
- Index(es):
Relevant Pages
|