]> granicus.if.org Git - python/commitdiff
merge 70783 back to 26maint
authorJesse Noller <jnoller@gmail.com>
Mon, 30 Mar 2009 23:38:36 +0000 (23:38 +0000)
committerJesse Noller <jnoller@gmail.com>
Mon, 30 Mar 2009 23:38:36 +0000 (23:38 +0000)
Lib/test/test_multiprocessing.py
Misc/ACKS
Misc/NEWS
Modules/_multiprocessing/semaphore.c

index d2503f619cf37a0f9ef071ad47a3bbe48b94636e..29323a5e97d03c2695b0dd43443917f19ffbd4dc 100644 (file)
@@ -548,6 +548,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):
 
index a869119aa0b8e57b360f2f42bd4d72d0cce62092..d902c136c22f24a0329bacaf2f22abd24f36c52e 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -251,6 +251,7 @@ Dinu Gherman
 Jonathan Giddy
 Johannes Gijsbers
 Michael Gilfix
+Tim Golden
 Chris Gonnerman
 David Goodger
 Hans de Graaff
index f882ed922ae7563335a63a83ed78a93afc6f93cc..d49fc0d2e96da8f5991ad04efa1fb3b79bd7a8b7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -92,6 +92,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.
index a5ba71e30ca8f701d138094a93b44b21f7624107..2c2fb10f2810302c1d1536b889273de5465412f6 100644 (file)
@@ -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"},