Skip to content

Commit e0ff495

Browse files
committed
make BlockingPortal.stop sync
1 parent 5591099 commit e0ff495

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/anyio/from_thread.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from warnings import warn
1010

1111
from ._core import _eventloop
12+
from ._core._compat import DeprecatedAwaitable
1213
from ._core._eventloop import get_asynclib, get_cancelled_exc_class, threadlocals
1314
from ._core._synchronization import Event
1415
from ._core._tasks import CancelScope, create_task_group
@@ -143,7 +144,7 @@ async def sleep_until_stopped(self) -> None:
143144
"""Sleep until :meth:`stop` is called."""
144145
await self._stop_event.wait()
145146

146-
async def stop(self, cancel_remaining: bool = False) -> None:
147+
def stop(self, cancel_remaining: bool = False) -> DeprecatedAwaitable:
147148
"""
148149
Signal the portal to shut down.
149150
@@ -159,6 +160,8 @@ async def stop(self, cancel_remaining: bool = False) -> None:
159160
if cancel_remaining:
160161
self._task_group.cancel_scope.cancel()
161162

163+
return DeprecatedAwaitable(self.stop)
164+
162165
async def _call_func(self, func: Callable, args: tuple, kwargs: Dict[str, Any],
163166
future: Future) -> None:
164167
def callback(f: Future) -> None:

0 commit comments

Comments
 (0)