Closed
Labels
bugSomething isn't working
Description
Priority: medium.
- Async hooks cannot use the client during
close()(client.py,close(): it sets the closed flag and closes the core beforeevents.drain()). An asyncoperation.failedhook that awaits and then writes an audit item getsShutdownError(reported ashook.failed), and the item is never written, although the docs say "the client waits for them at close()". events.drain()gathers its own task and tasks of other loops (events.py): an async hook that callsawait client.close()never finishes (at shutdownasyncio.runraisesRecursionErrorwhile cancelling it), and with a client used from two event loops (test_clients_work_across_event_loops), a hook still pending on the closed second loop makesclose()raiseValueError: The future belongs to a different loop, after the core is already closed.
Fix: drain the hook tasks of the current loop, except the calling task, before closing the core.
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
fix(client): close() waits for async hooks before it closes the client (