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
23398338
Commit
23398338
authored
Aug 14, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24867: Fix Task.get_stack() for 'async def' coroutines
parent
ac37ba07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+5
-1
Lib/test/test_asyncio/test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+32
-0
No files found.
Lib/asyncio/tasks.py
View file @
23398338
...
...
@@ -128,7 +128,11 @@ class Task(futures.Future):
returned for a suspended coroutine.
"""
frames
=
[]
f
=
self
.
_coro
.
gi_frame
try
:
# 'async def' coroutines
f
=
self
.
_coro
.
cr_frame
except
AttributeError
:
f
=
self
.
_coro
.
gi_frame
if
f
is
not
None
:
while
f
is
not
None
:
if
limit
is
not
None
:
...
...
Lib/test/test_asyncio/test_tasks.py
View file @
23398338
...
...
@@ -2,6 +2,7 @@
import
contextlib
import
functools
import
io
import
os
import
re
import
sys
...
...
@@ -162,6 +163,37 @@ class TaskTests(test_utils.TestCase):
'function is deprecated, use ensure_'
):
self
.
assertIs
(
f
,
asyncio
.
async
(
f
))
def
test_get_stack
(
self
):
T
=
None
@
asyncio
.
coroutine
def
foo
():
yield
from
bar
()
@
asyncio
.
coroutine
def
bar
():
# test get_stack()
f
=
T
.
get_stack
(
limit
=
1
)
try
:
self
.
assertEqual
(
f
[
0
].
f_code
.
co_name
,
'foo'
)
finally
:
f
=
None
# test print_stack()
file
=
io
.
StringIO
()
T
.
print_stack
(
limit
=
1
,
file
=
file
)
file
.
seek
(
0
)
tb
=
file
.
read
()
self
.
assertRegex
(
tb
,
r'foo\
(
\) running'
)
@
asyncio
.
coroutine
def
runner
():
nonlocal
T
T
=
asyncio
.
ensure_future
(
foo
(),
loop
=
self
.
loop
)
yield
from
T
self
.
loop
.
run_until_complete
(
runner
())
def
test_task_repr
(
self
):
self
.
loop
.
set_debug
(
False
)
...
...
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