summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/asyncio
diff options
context:
space:
mode:
authorshadchin <[email protected]>2023-10-03 23:32:21 +0300
committershadchin <[email protected]>2023-10-03 23:48:51 +0300
commit01ffd024041ac933854c367fb8d1b5682d19883f (patch)
treeb70aa497ba132a133ccece49f7763427dcd0743f /contrib/tools/python3/src/Lib/asyncio
parenta33fdb9a34581fd124e92535153b1f1fdeca6aaf (diff)
Update Python 3 to 3.11.6
Diffstat (limited to 'contrib/tools/python3/src/Lib/asyncio')
-rw-r--r--contrib/tools/python3/src/Lib/asyncio/streams.py5
-rw-r--r--contrib/tools/python3/src/Lib/asyncio/subprocess.py12
-rw-r--r--contrib/tools/python3/src/Lib/asyncio/tasks.py22
3 files changed, 25 insertions, 14 deletions
diff --git a/contrib/tools/python3/src/Lib/asyncio/streams.py b/contrib/tools/python3/src/Lib/asyncio/streams.py
index 3d577f12704..19d9154b66d 100644
--- a/contrib/tools/python3/src/Lib/asyncio/streams.py
+++ b/contrib/tools/python3/src/Lib/asyncio/streams.py
@@ -67,9 +67,8 @@ async def start_server(client_connected_cb, host=None, port=None, *,
positional host and port, with various optional keyword arguments
following. The return value is the same as loop.create_server().
- Additional optional keyword arguments are loop (to set the event loop
- instance to use) and limit (to set the buffer limit passed to the
- StreamReader).
+ Additional optional keyword argument is limit (to set the buffer
+ limit passed to the StreamReader).
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
diff --git a/contrib/tools/python3/src/Lib/asyncio/subprocess.py b/contrib/tools/python3/src/Lib/asyncio/subprocess.py
index c380bbb0ee9..da4f00a4a07 100644
--- a/contrib/tools/python3/src/Lib/asyncio/subprocess.py
+++ b/contrib/tools/python3/src/Lib/asyncio/subprocess.py
@@ -147,14 +147,16 @@ class Process:
async def _feed_stdin(self, input):
debug = self._loop.get_debug()
- self.stdin.write(input)
- if debug:
- logger.debug(
- '%r communicate: feed stdin (%s bytes)', self, len(input))
try:
+ self.stdin.write(input)
+ if debug:
+ logger.debug(
+ '%r communicate: feed stdin (%s bytes)', self, len(input))
+
await self.stdin.drain()
except (BrokenPipeError, ConnectionResetError) as exc:
- # communicate() ignores BrokenPipeError and ConnectionResetError
+ # communicate() ignores BrokenPipeError and ConnectionResetError.
+ # write() and drain() can raise these exceptions.
if debug:
logger.debug('%r communicate: stdin got %r', self, exc)
diff --git a/contrib/tools/python3/src/Lib/asyncio/tasks.py b/contrib/tools/python3/src/Lib/asyncio/tasks.py
index 3e07ce5294c..6ca545e30ac 100644
--- a/contrib/tools/python3/src/Lib/asyncio/tasks.py
+++ b/contrib/tools/python3/src/Lib/asyncio/tasks.py
@@ -81,15 +81,25 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
"""A coroutine wrapped in a Future."""
# An important invariant maintained while a Task not done:
+ # _fut_waiter is either None or a Future. The Future
+ # can be either done() or not done().
+ # The task can be in any of 3 states:
#
- # - Either _fut_waiter is None, and _step() is scheduled;
- # - or _fut_waiter is some Future, and _step() is *not* scheduled.
+ # - 1: _fut_waiter is not None and not _fut_waiter.done():
+ # __step() is *not* scheduled and the Task is waiting for _fut_waiter.
+ # - 2: (_fut_waiter is None or _fut_waiter.done()) and __step() is scheduled:
+ # the Task is waiting for __step() to be executed.
+ # - 3: _fut_waiter is None and __step() is *not* scheduled:
+ # the Task is currently executing (in __step()).
#
- # The only transition from the latter to the former is through
- # _wakeup(). When _fut_waiter is not None, one of its callbacks
- # must be _wakeup().
+ # * In state 1, one of the callbacks of __fut_waiter must be __wakeup().
+ # * The transition from 1 to 2 happens when _fut_waiter becomes done(),
+ # as it schedules __wakeup() to be called (which calls __step() so
+ # we way that __step() is scheduled).
+ # * It transitions from 2 to 3 when __step() is executed, and it clears
+ # _fut_waiter to None.
- # If False, don't log a message if the task is destroyed whereas its
+ # If False, don't log a message if the task is destroyed while its
# status is still pending
_log_destroy_pending = True