Skip to content

Commit 62a559a

Browse files
[3.13] gh-117657: Acquire a critical section around SemLock.__{enter,exit}__ (GH-118812) (#118856)
These methods are purely wrappers around `Semlock.{acquire,release}`, which expect a critical section to be held. (cherry picked from commit c30d8e5) Co-authored-by: mpage <mpage@meta.com>
1 parent 738877a commit 62a559a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Modules/_multiprocessing/clinic/semaphore.c.h

+10-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_multiprocessing/semaphore.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -682,19 +682,21 @@ _multiprocessing_SemLock__after_fork_impl(SemLockObject *self)
682682
}
683683

684684
/*[clinic input]
685+
@critical_section
685686
_multiprocessing.SemLock.__enter__
686687
687688
Enter the semaphore/lock.
688689
[clinic start generated code]*/
689690

690691
static PyObject *
691692
_multiprocessing_SemLock___enter___impl(SemLockObject *self)
692-
/*[clinic end generated code: output=beeb2f07c858511f input=c5e27d594284690b]*/
693+
/*[clinic end generated code: output=beeb2f07c858511f input=d35c9860992ee790]*/
693694
{
694695
return _multiprocessing_SemLock_acquire_impl(self, 1, Py_None);
695696
}
696697

697698
/*[clinic input]
699+
@critical_section
698700
_multiprocessing.SemLock.__exit__
699701
700702
exc_type: object = None
@@ -709,7 +711,7 @@ static PyObject *
709711
_multiprocessing_SemLock___exit___impl(SemLockObject *self,
710712
PyObject *exc_type,
711713
PyObject *exc_value, PyObject *exc_tb)
712-
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=7d644b64a89903f8]*/
714+
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=1610c8cc3e0e337e]*/
713715
{
714716
return _multiprocessing_SemLock_release_impl(self);
715717
}

0 commit comments

Comments
 (0)