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
cced0762
Commit
cced0762
authored
Nov 27, 2013
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio: Fix get_event_loop() to call set_event_loop() when setting the loop. By Anthony Baire.
parent
1314ef73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
Lib/asyncio/events.py
Lib/asyncio/events.py
+1
-1
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+16
-0
No files found.
Lib/asyncio/events.py
View file @
cced0762
...
...
@@ -360,7 +360,7 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
if
(
self
.
_local
.
_loop
is
None
and
not
self
.
_local
.
_set_called
and
isinstance
(
threading
.
current_thread
(),
threading
.
_MainThread
)):
self
.
_local
.
_loop
=
self
.
new_event_loop
(
)
self
.
set_event_loop
(
self
.
new_event_loop
()
)
assert
self
.
_local
.
_loop
is
not
None
,
\
(
'There is no current event loop in thread %r.'
%
threading
.
current_thread
().
name
)
...
...
Lib/test/test_asyncio/test_events.py
View file @
cced0762
...
...
@@ -1599,6 +1599,22 @@ class PolicyTests(unittest.TestCase):
self
.
assertIs
(
loop
,
policy
.
get_event_loop
())
loop
.
close
()
def
test_get_event_loop_calls_set_event_loop
(
self
):
policy
=
self
.
create_policy
()
with
unittest
.
mock
.
patch
.
object
(
policy
,
"set_event_loop"
,
wraps
=
policy
.
set_event_loop
)
as
m_set_event_loop
:
loop
=
policy
.
get_event_loop
()
# policy._local._loop must be set through .set_event_loop()
# (the unix DefaultEventLoopPolicy needs this call to attach
# the child watcher correctly)
m_set_event_loop
.
assert_called_with
(
loop
)
loop
.
close
()
def
test_get_event_loop_after_set_none
(
self
):
policy
=
self
.
create_policy
()
policy
.
set_event_loop
(
None
)
...
...
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