|
16 | 16 | from io import FileIO, TextIOWrapper
|
17 | 17 | from logging import StreamHandler
|
18 | 18 | from pathlib import Path
|
| 19 | +from typing import Optional |
19 | 20 |
|
20 | 21 | import zmq
|
21 | 22 | import zmq.asyncio
|
@@ -144,9 +145,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, ConnectionFileMix
|
144 | 145 | stdin_socket = Any()
|
145 | 146 | iopub_socket = Any()
|
146 | 147 |
|
147 |
| - iopub_thread: BaseThread |
148 |
| - control_thread: BaseThread |
149 |
| - shell_channel_thread: BaseThread |
| 148 | + iopub_thread: Optional[IOPubThread] = Instance(IOPubThread, allow_none=True) # type:ignore[assignment] |
| 149 | + control_thread: Optional[BaseThread] = Instance(BaseThread, allow_none=True) # type:ignore[assignment] |
| 150 | + shell_channel_thread: Optional[BaseThread] = Instance(BaseThread, allow_none=True) # type:ignore[assignment] |
150 | 151 |
|
151 | 152 | _ports = Dict()
|
152 | 153 |
|
@@ -263,7 +264,7 @@ def _bind_socket(self, s, port):
|
263 | 264 | raise
|
264 | 265 | return None
|
265 | 266 |
|
266 |
| - def write_connection_file(self): |
| 267 | + def write_connection_file(self, **kwargs: t.Any) -> None: |
267 | 268 | """write connection info to JSON file"""
|
268 | 269 | cf = self.abs_connection_file
|
269 | 270 | connection_info = dict(
|
@@ -403,15 +404,15 @@ def close(self):
|
403 | 404 | if self.heartbeat:
|
404 | 405 | self.log.debug("Closing heartbeat channel")
|
405 | 406 | self.heartbeat.context.term()
|
406 |
| - if self.iopub_thread: |
| 407 | + if self.iopub_thread is not None: |
407 | 408 | self.log.debug("Closing iopub channel")
|
408 | 409 | self.iopub_thread.stop()
|
409 | 410 | self.iopub_thread.close()
|
410 |
| - if self.control_thread and self.control_thread.is_alive(): |
| 411 | + if self.control_thread is not None and self.control_thread.is_alive(): |
411 | 412 | self.log.debug("Closing control thread")
|
412 | 413 | self.control_thread.stop()
|
413 | 414 | self.control_thread.join()
|
414 |
| - if self.shell_channel_thread and self.shell_channel_thread.is_alive(): |
| 415 | + if self.shell_channel_thread is not None and self.shell_channel_thread.is_alive(): |
415 | 416 | self.log.debug("Closing shell channel thread")
|
416 | 417 | self.shell_channel_thread.stop()
|
417 | 418 | self.shell_channel_thread.join()
|
|
0 commit comments