mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
asyncio/windows_events.py: use more revelant names to overlapped callbacks
For example: "finish_recv", not just "finish".
This commit is contained in:
parent
984689821d
commit
c89c8a7be9
2 changed files with 11 additions and 12 deletions
|
@ -702,8 +702,7 @@ class _SelectorSslTransport(_SelectorTransport):
|
||||||
if self._buffer:
|
if self._buffer:
|
||||||
try:
|
try:
|
||||||
n = self._sock.send(self._buffer)
|
n = self._sock.send(self._buffer)
|
||||||
except (BlockingIOError, InterruptedError,
|
except (BlockingIOError, InterruptedError, ssl.SSLWantWriteError):
|
||||||
ssl.SSLWantWriteError):
|
|
||||||
n = 0
|
n = 0
|
||||||
except ssl.SSLWantReadError:
|
except ssl.SSLWantReadError:
|
||||||
n = 0
|
n = 0
|
||||||
|
|
|
@ -213,7 +213,7 @@ class IocpProactor:
|
||||||
else:
|
else:
|
||||||
ov.ReadFile(conn.fileno(), nbytes)
|
ov.ReadFile(conn.fileno(), nbytes)
|
||||||
|
|
||||||
def finish(trans, key, ov):
|
def finish_recv(trans, key, ov):
|
||||||
try:
|
try:
|
||||||
return ov.getresult()
|
return ov.getresult()
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
|
@ -222,7 +222,7 @@ class IocpProactor:
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return self._register(ov, conn, finish)
|
return self._register(ov, conn, finish_recv)
|
||||||
|
|
||||||
def send(self, conn, buf, flags=0):
|
def send(self, conn, buf, flags=0):
|
||||||
self._register_with_iocp(conn)
|
self._register_with_iocp(conn)
|
||||||
|
@ -232,7 +232,7 @@ class IocpProactor:
|
||||||
else:
|
else:
|
||||||
ov.WriteFile(conn.fileno(), buf)
|
ov.WriteFile(conn.fileno(), buf)
|
||||||
|
|
||||||
def finish(trans, key, ov):
|
def finish_send(trans, key, ov):
|
||||||
try:
|
try:
|
||||||
return ov.getresult()
|
return ov.getresult()
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
|
@ -241,7 +241,7 @@ class IocpProactor:
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return self._register(ov, conn, finish)
|
return self._register(ov, conn, finish_send)
|
||||||
|
|
||||||
def accept(self, listener):
|
def accept(self, listener):
|
||||||
self._register_with_iocp(listener)
|
self._register_with_iocp(listener)
|
||||||
|
@ -300,17 +300,17 @@ class IocpProactor:
|
||||||
ov = _overlapped.Overlapped(NULL)
|
ov = _overlapped.Overlapped(NULL)
|
||||||
ov.ConnectNamedPipe(pipe.fileno())
|
ov.ConnectNamedPipe(pipe.fileno())
|
||||||
|
|
||||||
def finish(trans, key, ov):
|
def finish_accept_pipe(trans, key, ov):
|
||||||
ov.getresult()
|
ov.getresult()
|
||||||
return pipe
|
return pipe
|
||||||
|
|
||||||
return self._register(ov, pipe, finish)
|
return self._register(ov, pipe, finish_accept_pipe)
|
||||||
|
|
||||||
def connect_pipe(self, address):
|
def connect_pipe(self, address):
|
||||||
ov = _overlapped.Overlapped(NULL)
|
ov = _overlapped.Overlapped(NULL)
|
||||||
ov.WaitNamedPipeAndConnect(address, self._iocp, ov.address)
|
ov.WaitNamedPipeAndConnect(address, self._iocp, ov.address)
|
||||||
|
|
||||||
def finish(err, handle, ov):
|
def finish_connect_pipe(err, handle, ov):
|
||||||
# err, handle were arguments passed to PostQueuedCompletionStatus()
|
# err, handle were arguments passed to PostQueuedCompletionStatus()
|
||||||
# in a function run in a thread pool.
|
# in a function run in a thread pool.
|
||||||
if err == _overlapped.ERROR_SEM_TIMEOUT:
|
if err == _overlapped.ERROR_SEM_TIMEOUT:
|
||||||
|
@ -323,7 +323,7 @@ class IocpProactor:
|
||||||
else:
|
else:
|
||||||
return windows_utils.PipeHandle(handle)
|
return windows_utils.PipeHandle(handle)
|
||||||
|
|
||||||
return self._register(ov, None, finish, wait_for_post=True)
|
return self._register(ov, None, finish_connect_pipe, wait_for_post=True)
|
||||||
|
|
||||||
def wait_for_handle(self, handle, timeout=None):
|
def wait_for_handle(self, handle, timeout=None):
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
|
@ -339,7 +339,7 @@ class IocpProactor:
|
||||||
handle, self._iocp, ov.address, ms)
|
handle, self._iocp, ov.address, ms)
|
||||||
f = _WaitHandleFuture(wh, loop=self._loop)
|
f = _WaitHandleFuture(wh, loop=self._loop)
|
||||||
|
|
||||||
def finish(trans, key, ov):
|
def finish_wait_for_handle(trans, key, ov):
|
||||||
if not f.cancelled():
|
if not f.cancelled():
|
||||||
try:
|
try:
|
||||||
_overlapped.UnregisterWait(wh)
|
_overlapped.UnregisterWait(wh)
|
||||||
|
@ -355,7 +355,7 @@ class IocpProactor:
|
||||||
return (_winapi.WaitForSingleObject(handle, 0) ==
|
return (_winapi.WaitForSingleObject(handle, 0) ==
|
||||||
_winapi.WAIT_OBJECT_0)
|
_winapi.WAIT_OBJECT_0)
|
||||||
|
|
||||||
self._cache[ov.address] = (f, ov, None, finish)
|
self._cache[ov.address] = (f, ov, None, finish_wait_for_handle)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def _register_with_iocp(self, obj):
|
def _register_with_iocp(self, obj):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue