summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-03-30 23:38:36 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-03-30 23:38:36 (GMT)
commitf0d21c751b306e3192ddc81dfd28e74b8816e57b (patch)
tree7d259f79cfb33959ecc3f799b5e4bd1cd3d9dab6
parentd5ac4447bae5a1cb03b8b4ac6cd1d061de03493c (diff)
downloadcpython-f0d21c751b306e3192ddc81dfd28e74b8816e57b.zip
cpython-f0d21c751b306e3192ddc81dfd28e74b8816e57b.tar.gz
cpython-f0d21c751b306e3192ddc81dfd28e74b8816e57b.tar.bz2
merge 70783 back to 26maint
-rw-r--r--Lib/test/test_multiprocessing.py4
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_multiprocessing/semaphore.c2
4 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index d2503f6..29323a5 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -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):
diff --git a/Misc/ACKS b/Misc/ACKS
index a869119..d902c13 100644
--- 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
diff --git a/Misc/NEWS b/Misc/NEWS
index f882ed9..d49fc0d 100644
--- 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.
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"},