-
-
Notifications
You must be signed in to change notification settings - Fork 731
Description
The API documentation for watchdog.utils.BaseThread states that the daemon attribute's initial value is inherited from the creating thread:
daemon
A boolean value indicating whether this thread is a daemon thread.This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
However, the actual source code explicitly sets daemon=True unconditionally in __init__, overriding any inheritance:
class BaseThread(threading.Thread):
""" Convenience class for creating stoppable threads. """
def __init__(self):
threading.Thread.__init__(self)
if hasattr(self, 'daemon'):
self.daemon = True
else:
self.setDaemon(True)BaseThread is then used as a base class for EventEmitter and EventDispatcher (without further daemon overrides). Also, when starting an Observer from the main thread threading.enumerate() shows daemon threads:
[<_MainThread(MainThread, started 140704559562176)>, <FSEventsObserver(Thread-1, started daemon 123145565335552)>, <FSEventsEmitter(Thread-2, started daemon 123145582125056)>].
Unless I'm missing something there is a mismatch between the code and the documentation.
Thanks!