Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5da05491
Commit
5da05491
authored
Jan 22, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.4 (asyncio)
parents
1d51ba6a
2b77c546
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
26 deletions
+19
-26
Lib/asyncio/windows_events.py
Lib/asyncio/windows_events.py
+17
-24
Modules/overlapped.c
Modules/overlapped.c
+2
-2
No files found.
Lib/asyncio/windows_events.py
View file @
5da05491
...
@@ -490,16 +490,21 @@ class IocpProactor:
...
@@ -490,16 +490,21 @@ class IocpProactor:
def
accept_pipe
(
self
,
pipe
):
def
accept_pipe
(
self
,
pipe
):
self
.
_register_with_iocp
(
pipe
)
self
.
_register_with_iocp
(
pipe
)
ov
=
_overlapped
.
Overlapped
(
NULL
)
ov
=
_overlapped
.
Overlapped
(
NULL
)
ov
.
ConnectNamedPipe
(
pipe
.
fileno
())
connected
=
ov
.
ConnectNamedPipe
(
pipe
.
fileno
())
if
connected
:
# ConnectNamePipe() failed with ERROR_PIPE_CONNECTED which means
# that the pipe is connected. There is no need to wait for the
# completion of the connection.
f
=
futures
.
Future
(
loop
=
self
.
_loop
)
f
.
set_result
(
pipe
)
return
f
def
finish_accept_pipe
(
trans
,
key
,
ov
):
def
finish_accept_pipe
(
trans
,
key
,
ov
):
ov
.
getresult
()
ov
.
getresult
()
return
pipe
return
pipe
# FIXME: Tulip issue 196: why do we need register=False?
return
self
.
_register
(
ov
,
pipe
,
finish_accept_pipe
)
# See also the comment in the _register() method
return
self
.
_register
(
ov
,
pipe
,
finish_accept_pipe
,
register
=
False
)
def
_connect_pipe
(
self
,
fut
,
address
,
delay
):
def
_connect_pipe
(
self
,
fut
,
address
,
delay
):
# Unfortunately there is no way to do an overlapped connect to a pipe.
# Unfortunately there is no way to do an overlapped connect to a pipe.
...
@@ -581,15 +586,14 @@ class IocpProactor:
...
@@ -581,15 +586,14 @@ class IocpProactor:
# to avoid sending notifications to completion port of ops
# to avoid sending notifications to completion port of ops
# that succeed immediately.
# that succeed immediately.
def
_register
(
self
,
ov
,
obj
,
callback
,
def
_register
(
self
,
ov
,
obj
,
callback
):
wait_for_post
=
False
,
register
=
True
):
# Return a future which will be set with the result of the
# Return a future which will be set with the result of the
# operation when it completes. The future's value is actually
# operation when it completes. The future's value is actually
# the value returned by callback().
# the value returned by callback().
f
=
_OverlappedFuture
(
ov
,
loop
=
self
.
_loop
)
f
=
_OverlappedFuture
(
ov
,
loop
=
self
.
_loop
)
if
f
.
_source_traceback
:
if
f
.
_source_traceback
:
del
f
.
_source_traceback
[
-
1
]
del
f
.
_source_traceback
[
-
1
]
if
not
ov
.
pending
and
not
wait_for_post
:
if
not
ov
.
pending
:
# The operation has completed, so no need to postpone the
# The operation has completed, so no need to postpone the
# work. We cannot take this short cut if we need the
# work. We cannot take this short cut if we need the
# NumberOfBytes, CompletionKey values returned by
# NumberOfBytes, CompletionKey values returned by
...
@@ -605,18 +609,11 @@ class IocpProactor:
...
@@ -605,18 +609,11 @@ class IocpProactor:
# Register the overlapped operation to keep a reference to the
# Register the overlapped operation to keep a reference to the
# OVERLAPPED object, otherwise the memory is freed and Windows may
# OVERLAPPED object, otherwise the memory is freed and Windows may
# read uninitialized memory.
# read uninitialized memory.
#
# For an unknown reason, ConnectNamedPipe() behaves differently:
# Register the overlapped operation for later. Note that
# the completion is not notified by GetOverlappedResult() if we
# we only store obj to prevent it from being garbage
# already called GetOverlappedResult(). For this specific case, we
# collected too early.
# don't expect notification (register is set to False).
self
.
_cache
[
ov
.
address
]
=
(
f
,
ov
,
obj
,
callback
)
else
:
register
=
True
if
register
:
# Register the overlapped operation for later. Note that
# we only store obj to prevent it from being garbage
# collected too early.
self
.
_cache
[
ov
.
address
]
=
(
f
,
ov
,
obj
,
callback
)
return
f
return
f
def
_unregister
(
self
,
ov
):
def
_unregister
(
self
,
ov
):
...
@@ -708,10 +705,6 @@ class IocpProactor:
...
@@ -708,10 +705,6 @@ class IocpProactor:
elif
isinstance
(
fut
,
_WaitCancelFuture
):
elif
isinstance
(
fut
,
_WaitCancelFuture
):
# _WaitCancelFuture must not be cancelled
# _WaitCancelFuture must not be cancelled
pass
pass
elif
fut
.
done
():
# FIXME: Tulip issue 196: remove this case, it should not
# happen
del
self
.
_cache
[
address
]
else
:
else
:
try
:
try
:
fut
.
cancel
()
fut
.
cancel
()
...
...
Modules/overlapped.c
View file @
5da05491
...
@@ -1117,10 +1117,10 @@ Overlapped_ConnectNamedPipe(OverlappedObject *self, PyObject *args)
...
@@ -1117,10 +1117,10 @@ Overlapped_ConnectNamedPipe(OverlappedObject *self, PyObject *args)
switch
(
err
)
{
switch
(
err
)
{
case
ERROR_PIPE_CONNECTED
:
case
ERROR_PIPE_CONNECTED
:
mark_as_completed
(
&
self
->
overlapped
);
mark_as_completed
(
&
self
->
overlapped
);
Py_RETURN_
NON
E
;
Py_RETURN_
TRU
E
;
case
ERROR_SUCCESS
:
case
ERROR_SUCCESS
:
case
ERROR_IO_PENDING
:
case
ERROR_IO_PENDING
:
Py_RETURN_
NON
E
;
Py_RETURN_
FALS
E
;
default:
default:
self
->
type
=
TYPE_NOT_STARTED
;
self
->
type
=
TYPE_NOT_STARTED
;
return
SetFromWindowsErr
(
err
);
return
SetFromWindowsErr
(
err
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment