diff --git a/.gitignore b/.gitignore index 26ac0bd9..7c0b0365 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ ENV/ # VScode .vscode/ + +# Idea IDE +.idea/ diff --git a/loguru/_handler.py b/loguru/_handler.py index 0217117c..fcbe88e1 100644 --- a/loguru/_handler.py +++ b/loguru/_handler.py @@ -1,5 +1,6 @@ import functools import json +import os import multiprocessing from threading import Thread @@ -66,7 +67,7 @@ def __init__( self._queue = None self._confirmation_event = None self._confirmation_lock = None - self._owner_process = None + self._owner_process_pid = None self._thread = None if self._is_formatter_dynamic: @@ -85,7 +86,7 @@ def __init__( self._queue = multiprocessing.SimpleQueue() self._confirmation_event = multiprocessing.Event() self._confirmation_lock = multiprocessing.Lock() - self._owner_process = multiprocessing.current_process() + self._owner_process_pid = os.getpid() self._thread = Thread( target=self._queued_writer, daemon=True, name="loguru-writer-%d" % self._id ) @@ -184,7 +185,7 @@ def stop(self): with self._lock: self._stopped = True if self._enqueue: - if self._owner_process != multiprocessing.current_process(): + if self._owner_process_pid != os.getpid(): return self._queue.put(None) self._thread.join() @@ -201,7 +202,7 @@ def complete_queue(self): self._confirmation_event.clear() async def complete_async(self): - if self._enqueue and self._owner_process != multiprocessing.current_process(): + if self._enqueue and self._owner_process_pid != os.getpid(): return with self._lock: