Skip to content

Commit

Permalink
Use an event variable to tell the notify queue to drain
Browse files Browse the repository at this point in the history
Intended to speed up the notify queue shut down if there are pending
events when running tests that repeatedly create and destroy llfuse
sessions.
  • Loading branch information
tetron committed Mar 14, 2024
1 parent 7b6a47a commit db9a169
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/fuse_api.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions src/llfuse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/misc.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit db9a169

Please sign in to comment.