Fix VERBOSE level not registered in multiprocessing workers#546
Fix VERBOSE level not registered in multiprocessing workers#546
Conversation
Signed-off-by: Sameer Chaturvedi <sameerc@mit.edu>
|
yes, I was able to replicate it on a linux laptop: export REPO="git+https://github.com/mit-psfc/disruption-py"
this hinges on using with your fix, both work:
BUT it does not look like I can switch log level anymore with python 3.14 (!):
I read again the release notes for 3.14, but I could not see anything that might help.
|
Confirmed on macOS (Python 3.11, This is pre-existing and separate from the VERBOSE registration fix in this PR ; on Reproduction: # /tmp/test_loglevel.py
if __name__ == '__main__':
from disruption_py.workflow import get_shots_data
result = get_shots_data(
shotlist_setting=[30420],
num_processes=1,
log_settings="CRITICAL",
)
$ poetry run python /tmp/test_loglevel.py
# Expected: only CRITICAL messages
# Actual: VERBOSE and DEBUG output from worker still appears:
# 2026-04-07 16:07:24.968 | DEBUG | disruption_py.inout.xr:__init__:41 - ...
# 2026-04-07 16:07:34.978 | VERBOSE | disruption_py.core.physics_method.decorator:timed_wrapper:61 - ...Can address the handler config in a follow-up PR (e.g., Pool(initializer=...) to configure handlers in workers). Want me to keep this PR scoped to just the level registration, or bundle the handler fix here? |
Summary
setup_logging()to module-level inlog_settings.py, so it's available in any process that imports the modulespawn) and Linux with Python 3.14+ (forkserver)Problem
The custom VERBOSE level and
logger.verbose()method are registered insidesetup_logging(), which only runs in the main process. Worker processes created bymultiprocessing.Pooldon't inherit this on:spawn)forktoforkserver)This causes
params.logger.verbose()in the physics method decorator (decorator.py:61) to throwAttributeError. The broadexceptinpopulate_methodcatches it and replaces the method's real result with NaN -- for every method, every shot.Verification
Tested with MAST shot 30420,
num_processes=1, macOS + Python 3.11 (spawn):dev: 0/33 parameters have data (100% NaN, every method errors withAttributeError)power_nbimissing for this shot)Greg also confirmed: dies on Linux + Python 3.14 (
forkserver), works from this branch.Test plan
spawn— all NaN ondev, real data on fix branchforkserver)References [edit by GLT]
https://docs.python.org/3/whatsnew/3.14.html#concurrent-futures