Commit cd14b0e
authored
Fix channel cleanup by closing streams before stopping ioloop thread (#1089)
* Fix channel cleanup by closing streams before stopping ioloop thread
The change in PR #1076 added 'finally: loop.close()' to IOLoopThread.run(),
which closes the asyncio event loop before ZMQ streams have been properly
unregistered. This caused errors during teardown when downstream projects
like qtconsole tried to check if channels were closed.
The fix ensures that channel streams are explicitly closed (via close())
while the ioloop is still running, before calling stop_channels() on the
parent class and stopping the ioloop thread. This allows the ZMQ streams
to be properly unregistered from the event loop before it's closed.
* Fix _exiting to be instance variable, not shared class variable
The _exiting flag was defined as a class variable, meaning when one
IOLoopThread called stop() and set _exiting = True, it affected ALL
IOLoopThread instances. This caused subsequent kernels to fail to start
because _async_run() would immediately exit.
By initializing self._exiting = False in __init__, each IOLoopThread
instance now has its own exit flag. The class-level _exiting is still
used by _notice_exit() for interpreter shutdown cleanup.1 parent 49a4376 commit cd14b0e
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
233 | 240 | | |
234 | 241 | | |
235 | 242 | | |
| |||
333 | 340 | | |
334 | 341 | | |
335 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
336 | 356 | | |
337 | 357 | | |
338 | 358 | | |
| |||
0 commit comments