aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-04-28 21:17:44 +0300
committershadchin <shadchin@yandex-team.com>2024-04-28 21:25:54 +0300
commita55d99a3eb72f90355bc146baeda18aa7eb97352 (patch)
treeb17cfed786effe8b81bba022239d6729f716fbeb /contrib/tools/python3/Lib/asyncio/base_events.py
parent67bf49d08acf1277eff4c336021ac22d964bb4c4 (diff)
downloadydb-a55d99a3eb72f90355bc146baeda18aa7eb97352.tar.gz
Update Python 3 to 3.12.3
7d09de7d8b99ea2be554ef0fc61276942ca9c2e1
Diffstat (limited to 'contrib/tools/python3/Lib/asyncio/base_events.py')
-rw-r--r--contrib/tools/python3/Lib/asyncio/base_events.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/contrib/tools/python3/Lib/asyncio/base_events.py b/contrib/tools/python3/Lib/asyncio/base_events.py
index c16c445bde3..29eff0499cb 100644
--- a/contrib/tools/python3/Lib/asyncio/base_events.py
+++ b/contrib/tools/python3/Lib/asyncio/base_events.py
@@ -45,6 +45,7 @@ from . import protocols
from . import sslproto
from . import staggered
from . import tasks
+from . import timeouts
from . import transports
from . import trsock
from .log import logger
@@ -596,23 +597,24 @@ class BaseEventLoop(events.AbstractEventLoop):
thread = threading.Thread(target=self._do_shutdown, args=(future,))
thread.start()
try:
- await future
- finally:
- thread.join(timeout)
-
- if thread.is_alive():
+ async with timeouts.timeout(timeout):
+ await future
+ except TimeoutError:
warnings.warn("The executor did not finishing joining "
- f"its threads within {timeout} seconds.",
- RuntimeWarning, stacklevel=2)
+ f"its threads within {timeout} seconds.",
+ RuntimeWarning, stacklevel=2)
self._default_executor.shutdown(wait=False)
+ else:
+ thread.join()
def _do_shutdown(self, future):
try:
self._default_executor.shutdown(wait=True)
if not self.is_closed():
- self.call_soon_threadsafe(future.set_result, None)
+ self.call_soon_threadsafe(futures._set_result_unless_cancelled,
+ future, None)
except Exception as ex:
- if not self.is_closed():
+ if not self.is_closed() and not future.cancelled():
self.call_soon_threadsafe(future.set_exception, ex)
def _check_running(self):