HyperionGray / trio-chrome-devtools-protocol

Trio driver for Chrome DevTools Protocol (CDP)
MIT License
60 stars 17 forks source link

Event listeners are not closed correctly during connection close #8

Open mehaase opened 4 years ago

mehaase commented 4 years ago

In #5 I added aclose() to the connection class so that the underlying WebSocket can be closed, and future calls to conn.execute() will raise ConnectionClosed. This is not quite enough cleanup, however, because the sessions belonging to that connection are not torn down. For example, if a caller is inside an async for session.listen(...): loop, I believe that loop will currently hang forever, because it does not receive a signal that the connection is closed. The proper behavior would be to close all open channels, which will cause all async for session.listen(...) loops to exit gracefully.

There may be other, similar issues regarding session tear-down.