diff options
author | Jesse Noller <jnoller@gmail.com> | 2009-03-30 23:29:31 (GMT) |
---|---|---|
committer | Jesse Noller <jnoller@gmail.com> | 2009-03-30 23:29:31 (GMT) |
commit | 82eb5902ce169be81110c79662b772b904cd00fc (patch) | |
tree | 53aa2270a045dd78e0d4cfeef20c3ad23b18cd03 | |
parent | d7bf8a54787d0c3520a0788224537acab2491b38 (diff) | |
download | cpython-82eb5902ce169be81110c79662b772b904cd00fc.zip cpython-82eb5902ce169be81110c79662b772b904cd00fc.tar.gz cpython-82eb5902ce169be81110c79662b772b904cd00fc.tar.bz2 |
merge in patch from tim golden to fix contextmanager support for mp.Lock()
-rw-r--r-- | Lib/test/test_multiprocessing.py | 4 | ||||
-rw-r--r-- | Misc/ACKS | 2 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_multiprocessing/semaphore.c | 2 |
4 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 105a743..a446ac3 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -546,6 +546,10 @@ class _TestLock(BaseTestCase): self.assertEqual(lock.release(), None) self.assertRaises((AssertionError, RuntimeError), lock.release) + def test_lock_context(self): + with self.Lock(): + pass + class _TestSemaphore(BaseTestCase): @@ -256,6 +256,7 @@ Dinu Gherman Jonathan Giddy Johannes Gijsbers Michael Gilfix +Tim Golden Chris Gonnerman David Goodger Hans de Graaff @@ -789,4 +790,3 @@ Siebren van der Zee Uwe Zessin Tarek Ziad Peter Åstrand -Jesse Noller @@ -199,6 +199,9 @@ Core and Builtins Library ------- +- Issue #5261: Patch multiprocessing's semaphore.c to support context + manager use: "with multiprocessing.Lock()" works now. + - Issue #5177: Multiprocessing's SocketListener class now uses socket.SO_REUSEADDR on all connections so that the user no longer needs to wait 120 seconds for the socket to expire. diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index a5ba71e..2c2fb10 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -546,7 +546,7 @@ static PyMethodDef semlock_methods[] = { "acquire the semaphore/lock"}, {"release", (PyCFunction)semlock_release, METH_NOARGS, "release the semaphore/lock"}, - {"__enter__", (PyCFunction)semlock_acquire, METH_VARARGS, + {"__enter__", (PyCFunction)semlock_acquire, METH_VARARGS | METH_KEYWORDS, "enter the semaphore/lock"}, {"__exit__", (PyCFunction)semlock_release, METH_VARARGS, "exit the semaphore/lock"}, |