Skip to content

Sync process name with stdlib multiprocessing for logging (#143) - #283

Open
M-Colley wants to merge 1 commit into
uqfoundation:masterfrom
M-Colley:fix/issue-143-logging-process-name
Open

M-Colley wants to merge 1 commit into
uqfoundation:masterfrom
M-Colley:fix/issue-143-logging-process-name

Conversation

@M-Colley

Copy link
Copy Markdown

Stdlib logging records report 'MainProcess' inside multiprocess child processes. Specifically, logging.LogRecord.init reads processName from sys.modules['multiprocessing'].current_process().name, which stays at its initial value when multiprocess updates its own current process object. Fixes #143.

BaseProcess._bootstrap and BaseProcess.name.setter now call _sync_logging_process_name across all supported CPython and PyPy trees. Consequently, stdlib multiprocessing.current_process().name stays synchronized with the active multiprocess process name while guarding against alias recursion. Regression tests in multiprocess/tests/test_logging_process_name.py verify custom process names, default process names, Pool workers, dynamic renaming, and coexistence with stdlib multiprocessing.Process.

Verification ran c:\Users\markc\OneDrive\Desktop\oss-sweep.oss-sweep\tools_venv2\Scripts\python.exe c:\Users\markc\OneDrive\Desktop\oss-sweep.oss-sweep\waves\w11\uqfoundation__multiprocess\py3.12\multiprocess\tests\test_logging_process_name.py -v and passed all 5 tests in 0.574s.

…on#143)

Update stdlib multiprocessing.current_process().name during
BaseProcess._bootstrap and current process renaming so stdlib logging
records report the multiprocess worker name. Fixes uqfoundation#143.

Signed-off-by: Mark Colley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Process name not propagated to logging library

1 participant