diff --git a/src/fuse_api.pxi b/src/fuse_api.pxi index a156f21..7ebd08d 100644 --- a/src/fuse_api.pxi +++ b/src/fuse_api.pxi @@ -301,9 +301,11 @@ def main(workers=None, handle_signals=True): on_exit.callback(lambda: restore_signal_handlers()) # Start notification handling thread + _notify_queue_shutdown.clear() t = threading.Thread(target=_notify_loop) t.daemon = True t.start() + on_exit.callback(_notify_queue_shutdown.set) on_exit.callback(_notify_queue.put, None, block=True, timeout=5) on_exit.callback(lambda: fuse_session_reset(session)) @@ -313,6 +315,7 @@ def main(workers=None, handle_signals=True): session_loop_single() else: session_loop_mt(workers) + t.join() if exc_info: # Re-raise expression from request handler diff --git a/src/llfuse.pyx b/src/llfuse.pyx index a8f5597..61dd46a 100644 --- a/src/llfuse.pyx +++ b/src/llfuse.pyx @@ -137,6 +137,9 @@ lock_released = NoLockManager.__new__(NoLockManager) cdef object _notify_queue _notify_queue = Queue(maxsize=1000) +cdef object _notify_queue_shutdown +_notify_queue_shutdown = threading.Event() + # Exported for access from Python code # (in the Cython source, we want ENOATTR to refer # to the C constant, not a Python object) diff --git a/src/misc.pxi b/src/misc.pxi index d93667c..04bbad3 100644 --- a/src/misc.pxi +++ b/src/misc.pxi @@ -267,7 +267,11 @@ def _notify_loop(): while True: req = _notify_queue.get() if req is None: - return + break + + if _notify_queue_shutdown.is_set(): + # Just drain the queue + continue if req.kind == NOTIFY_INVAL_INODE: if req.attr_only: