9
9
from warnings import warn
10
10
11
11
from ._core import _eventloop
12
+ from ._core ._compat import DeprecatedAwaitable
12
13
from ._core ._eventloop import get_asynclib , get_cancelled_exc_class , threadlocals
13
14
from ._core ._synchronization import Event
14
15
from ._core ._tasks import CancelScope , create_task_group
@@ -130,7 +131,7 @@ async def __aenter__(self) -> 'BlockingPortal':
130
131
async def __aexit__ (self , exc_type : Optional [Type [BaseException ]],
131
132
exc_val : Optional [BaseException ],
132
133
exc_tb : Optional [TracebackType ]) -> Optional [bool ]:
133
- await self .stop ()
134
+ self .stop ()
134
135
return await self ._task_group .__aexit__ (exc_type , exc_val , exc_tb )
135
136
136
137
def _check_running (self ) -> None :
@@ -143,7 +144,7 @@ async def sleep_until_stopped(self) -> None:
143
144
"""Sleep until :meth:`stop` is called."""
144
145
await self ._stop_event .wait ()
145
146
146
- async def stop (self , cancel_remaining : bool = False ) -> None :
147
+ def stop (self , cancel_remaining : bool = False ) -> DeprecatedAwaitable :
147
148
"""
148
149
Signal the portal to shut down.
149
150
@@ -159,6 +160,8 @@ async def stop(self, cancel_remaining: bool = False) -> None:
159
160
if cancel_remaining :
160
161
self ._task_group .cancel_scope .cancel ()
161
162
163
+ return DeprecatedAwaitable (self .stop )
164
+
162
165
async def _call_func (self , func : Callable , args : tuple , kwargs : Dict [str , Any ],
163
166
future : Future ) -> None :
164
167
def callback (f : Future ) -> None :
0 commit comments