|
1 | 1 | import asyncio |
2 | 2 | import os |
3 | | -from typing import Any, List, Literal, Optional, Union |
| 3 | +from typing import Any, Literal, Optional, Union |
4 | 4 |
|
5 | 5 | from ..jsonrpc2.protocol import rpc_method |
6 | 6 | from ..jsonrpc2.server import JsonRPCServer, JsonRpcServerMode, TcpParams |
7 | 7 | from ..utils import async_tools |
8 | | -from ..utils.async_tools import run_coroutine_from_thread_as_future_async |
| 8 | +from ..utils.async_tools import run_coroutine_from_thread |
9 | 9 | from ..utils.logging import LoggingDescriptor |
10 | 10 | from .dap_types import ( |
11 | 11 | ConfigurationDoneArguments, |
@@ -66,29 +66,12 @@ def __init__(self) -> None: |
66 | 66 |
|
67 | 67 | self._received_configuration_done_event = async_tools.Event() |
68 | 68 | self._received_configuration_done = False |
69 | | - self._sended_events: List[asyncio.Future[None]] = [] |
70 | 69 |
|
71 | 70 | Debugger.instance().send_event.add(self.on_debugger_send_event) |
72 | 71 |
|
73 | 72 | def on_debugger_send_event(self, sender: Any, event: Event) -> None: |
74 | | - def remove_future(future: "asyncio.Future[None]") -> None: |
75 | | - self._sended_events.remove(future) |
76 | | - |
77 | 73 | if self._loop is not None: |
78 | | - future = run_coroutine_from_thread_as_future_async(self.send_event_async, event, loop=self._loop) |
79 | | - self._sended_events.append(future) |
80 | | - future.add_done_callback(remove_future) |
81 | | - |
82 | | - async def wait_for_all_events_sended(self, timeout: float = 5) -> bool: |
83 | | - async def wait() -> bool: |
84 | | - while True: |
85 | | - if self._sended_events: |
86 | | - await asyncio.sleep(0.01) |
87 | | - else: |
88 | | - return True |
89 | | - return False |
90 | | - |
91 | | - return await asyncio.wait_for(asyncio.create_task(wait()), timeout) |
| 74 | + run_coroutine_from_thread(self.send_event_async, event, loop=self._loop) |
92 | 75 |
|
93 | 76 | @property |
94 | 77 | def connected(self) -> bool: |
|
0 commit comments