Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: fix async/test_connect.py deadlock in Python 3.12
There was a breaking change in `wait_closed()` in Python 3.12 that caused some tests from test_connect to hang indefinitely. The reason for that was the fact that `wait_closed()` was waiting for all handlers to finish their execution, while the handler expected `stop_event` to be set. `stop_event` was set only *after* `wait_closed()` would have finished and returned the control, which caused a deadlock. This commit fixes the deadlock by setting `stop_event` right before calling for `conn.disconnect()`. This makes sense, because at that moment handling more new requests is not needed as connection is going to be closed. The old call for `stop_event.set()` is kept for the unlikely case when there was a connection error and the execution did not reach `stop_event.set()` call in `try` block. If it was reached, this call will be a noop. [1]: python/cpython#104344 Signed-off-by: Mikhail Koviazin <[email protected]>
- Loading branch information