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
62dd6352
Commit
62dd6352
authored
May 06, 2014
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio: Fix the second half of issue #21447: race in _write_to_self().
parent
90a8125a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
Lib/asyncio/selector_events.py
Lib/asyncio/selector_events.py
+11
-4
Lib/test/test_asyncio/test_selector_events.py
Lib/test/test_asyncio/test_selector_events.py
+3
-2
No files found.
Lib/asyncio/selector_events.py
View file @
62dd6352
...
...
@@ -87,10 +87,17 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
pass
def
_write_to_self
(
self
):
try
:
self
.
_csock
.
send
(
b'x'
)
except
(
BlockingIOError
,
InterruptedError
):
pass
# This may be called from a different thread, possibly after
# _close_self_pipe() has been called or even while it is
# running. Guard for self._csock being None or closed. When
# a socket is closed, send() raises OSError (with errno set to
# EBADF, but let's not rely on the exact error code).
csock
=
self
.
_csock
if
csock
is
not
None
:
try
:
csock
.
send
(
b'x'
)
except
OSError
:
pass
def
_start_serving
(
self
,
protocol_factory
,
sock
,
sslcontext
=
None
,
server
=
None
):
...
...
Lib/test/test_asyncio/test_selector_events.py
View file @
62dd6352
...
...
@@ -121,8 +121,9 @@ class BaseSelectorEventLoopTests(unittest.TestCase):
self
.
assertIsNone
(
self
.
loop
.
_write_to_self
())
def
test_write_to_self_exception
(
self
):
self
.
loop
.
_csock
.
send
.
side_effect
=
OSError
()
self
.
assertRaises
(
OSError
,
self
.
loop
.
_write_to_self
)
# _write_to_self() swallows OSError
self
.
loop
.
_csock
.
send
.
side_effect
=
RuntimeError
()
self
.
assertRaises
(
RuntimeError
,
self
.
loop
.
_write_to_self
)
def
test_sock_recv
(
self
):
sock
=
mock
.
Mock
()
...
...
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