[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 c30d8e5d6c)

Co-authored-by: mpage <mpage@meta.com>
This commit is contained in:
Miss Islington (bot) 2024-05-09 18:31:38 +02:00 committed by GitHub
parent 738877a101
commit 62a559ac09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -682,6 +682,7 @@ _multiprocessing_SemLock__after_fork_impl(SemLockObject *self)
}
/*[clinic input]
@critical_section
_multiprocessing.SemLock.__enter__
Enter the semaphore/lock.
@ -689,12 +690,13 @@ Enter the semaphore/lock.
static PyObject *
_multiprocessing_SemLock___enter___impl(SemLockObject *self)
/*[clinic end generated code: output=beeb2f07c858511f input=c5e27d594284690b]*/
/*[clinic end generated code: output=beeb2f07c858511f input=d35c9860992ee790]*/
{
return _multiprocessing_SemLock_acquire_impl(self, 1, Py_None);
}
/*[clinic input]
@critical_section
_multiprocessing.SemLock.__exit__
exc_type: object = None
@ -709,7 +711,7 @@ static PyObject *
_multiprocessing_SemLock___exit___impl(SemLockObject *self,
PyObject *exc_type,
PyObject *exc_value, PyObject *exc_tb)
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=7d644b64a89903f8]*/
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=1610c8cc3e0e337e]*/
{
return _multiprocessing_SemLock_release_impl(self);
}