Skip to content

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

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
gh-116738: Wrap with try/finally
  • Loading branch information
yoney committed Jul 18, 2025
commit b8102af21b1984e57138572425ece2c715988325
18 changes: 10 additions & 8 deletions Lib/test/test_free_threading/test_syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ def worker():
"""
thread_id = threading.get_ident()
syslog.openlog(f"thread-id: {thread_id}")
for _ in range(5):
syslog.syslog("logline")
syslog.setlogmask(syslog.LOG_MASK(syslog.LOG_INFO))
syslog.syslog(syslog.LOG_INFO, "logline LOG_INFO")
syslog.setlogmask(syslog.LOG_MASK(syslog.LOG_ERR))
syslog.syslog(syslog.LOG_ERR, "logline LOG_ERR")
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
syslog.closelog()
try:
for _ in range(5):
syslog.syslog("logline")
syslog.setlogmask(syslog.LOG_MASK(syslog.LOG_INFO))
syslog.syslog(syslog.LOG_INFO, "logline LOG_INFO")
syslog.setlogmask(syslog.LOG_MASK(syslog.LOG_ERR))
syslog.syslog(syslog.LOG_ERR, "logline LOG_ERR")
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
finally:
syslog.closelog()

# Run the worker concurrently to exercise all these syslog functions
run_concurrently(
Expand Down
Loading