Skip to content

Commit

Permalink
pythongh-117657: Acquire a critical section around `SemLock.__{enter,…
Browse files Browse the repository at this point in the history
…exit}__` (python#118812)

These methods are purely wrappers around `Semlock.{acquire,release}`,
which expect a critical section to be held.
  • Loading branch information
mpage authored and SonicField committed May 10, 2024
1 parent ec921f7 commit 154a3f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Modules/_multiprocessing/clinic/semaphore.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Modules/_multiprocessing/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,19 +682,21 @@ _multiprocessing_SemLock__after_fork_impl(SemLockObject *self)
}

/*[clinic input]
@critical_section
_multiprocessing.SemLock.__enter__
Enter the semaphore/lock.
[clinic start generated code]*/

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
Expand All @@ -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);
}
Expand Down

0 comments on commit 154a3f5

Please sign in to comment.