-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-116738: Make syslog module thread-safe #136760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm wondering whether these functions are thread safe on other UNIX-like platforms, but I found that on some BSDs (OpenBSD1 and NetBSD) and on AIX2, some of these syslog related functions are not thread safe, and they provide alternative versions with the I'm not sure whether we should add locks for these functions on these platforms, or change the implementations to the But these platforms are not marked as supported in PEP113, so I think this is may not be a big issue for now. Footnotes |
@aisk - I think the current implementation should be thread-safe on those platforms on both builds. The GIL provides thread safety on the default build; a critical section provides thread-safety on the free-threaded builds. There is one notable exception, cpython/Modules/syslogmodule.c Lines 242 to 249 in 5f9e38f
I think we can address that in a follow up, if needed. |
Make the setlogmask() function in the syslog module thread-safe. These changes are relevant for scenarios where the GIL is disabled or when using subinterpreters.
Make the
setlogmask()
function in thesyslog
module thread-safe. These changes are relevant for scenarios where the GIL is disabled or when using subinterpreters.syslog()
,openlog()
, andcloselog()
in the syslog module are already handled for FT-Python using the@critical_section
on themodule
. However, there might be an issue withsyslog()
for subinterpreters on macOS.cpython/Modules/syslogmodule.c
Lines 242 to 245 in 03017a8
I will check/test the macOS subinterpreter and create a separate PR if necessary.
cc: @mpage @colesbury