File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,9 +95,17 @@ def format_datetime(dt: datetime.datetime):
9595 return dt .strftime ("%Y-%m-%dT%k:%M:%S.%f000" ) + tzstr
9696
9797
98+ _pid : int = os .getpid ()
99+
100+
101+ def _change_pid ():
102+ global _pid
103+ _pid = os .getpid ()
104+
105+
98106def reduce_thread_id (thread_id : int ) -> str :
99107 """Make a shorter thread identifier by hashing the original."""
100- return xxhash .xxh32 (thread_id .to_bytes (8 , "little" )).hexdigest ()[:4 ]
108+ return xxhash .xxh32 (( thread_id ^ _pid ) .to_bytes (8 , "little" )).hexdigest ()[:4 ]
101109
102110
103111def repr_array (arr : ndarray ) -> str :
@@ -324,6 +332,8 @@ def ensure_utf8_stream(stream):
324332 if not allow_trailing_dot :
325333 handler .emit = check_trailing_dot (handler .emit )
326334
335+ os .register_at_fork (after_in_child = _change_pid )
336+
327337
328338def set_context (context ):
329339 """Assign the logging context - an abstract object - to the current thread."""
You can’t perform that action at this time.
0 commit comments