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
48c66c3d
Commit
48c66c3d
authored
Jan 29, 2014
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio: wait_for() now accepts None as timeout (Victor Stinner).
parent
1e9a446e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+3
-0
Lib/test/test_asyncio/test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+11
-0
No files found.
Lib/asyncio/tasks.py
View file @
48c66c3d
...
...
@@ -394,6 +394,9 @@ def wait_for(fut, timeout, *, loop=None):
if
loop
is
None
:
loop
=
events
.
get_event_loop
()
if
timeout
is
None
:
return
(
yield
from
fut
)
waiter
=
futures
.
Future
(
loop
=
loop
)
timeout_handle
=
loop
.
call_later
(
timeout
,
_release_waiter
,
waiter
,
False
)
cb
=
functools
.
partial
(
_release_waiter
,
waiter
,
True
)
...
...
Lib/test/test_asyncio/test_tasks.py
View file @
48c66c3d
...
...
@@ -380,6 +380,17 @@ class TaskTests(unittest.TestCase):
self
.
assertEqual
(
foo_running
,
False
)
def
test_wait_for_blocking
(
self
):
loop
=
test_utils
.
TestLoop
()
self
.
addCleanup
(
loop
.
close
)
@
asyncio
.
coroutine
def
coro
():
return
'done'
res
=
loop
.
run_until_complete
(
asyncio
.
wait_for
(
coro
(),
timeout
=
None
,
loop
=
loop
))
self
.
assertEqual
(
res
,
'done'
)
def
test_wait_for_with_global_loop
(
self
):
def
gen
():
...
...
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