mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 15:42:10 +03:00
Refactor import concurrent.futures into _run_in_daemon_thread in traceroute.py
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
8c99ac78b7
commit
045385c35e
1 changed files with 2 additions and 2 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import concurrent.futures
|
||||
import json
|
||||
import platform
|
||||
import shutil
|
||||
|
|
@ -17,13 +16,14 @@ _T = TypeVar("_T")
|
|||
|
||||
|
||||
def _run_in_daemon_thread(func: Callable[..., _T], *args: object) -> asyncio.Future[_T]:
|
||||
from concurrent.futures import Future
|
||||
# asyncio.to_thread()/loop.run_in_executor(None, ...) queue work onto the
|
||||
# ThreadPoolExecutor-backed default executor, whose worker threads are non-daemon
|
||||
# and get joined by concurrent.futures' atexit handler. If the underlying call
|
||||
# (a blocking WinAPI IcmpSendEcho2) ever outlives its own timeout budget, that
|
||||
# join blocks process exit indefinitely. A raw daemon thread is never tracked
|
||||
# by that handler, so it can never hold the process open.
|
||||
result: concurrent.futures.Future = concurrent.futures.Future()
|
||||
result: Future = Future()
|
||||
|
||||
def _target() -> None:
|
||||
if not result.set_running_or_notify_cancel():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue