Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8)

Side by Side Diff: Lib/asyncio/tasks.py

Issue 24867: Asyncio Task.get_stack fails with native coroutines
Patch Set: Created 4 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Support for tasks, coroutines and the scheduler.""" 1 """Support for tasks, coroutines and the scheduler."""
2 2
3 __all__ = ['Task', 3 __all__ = ['Task',
4 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED', 4 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED',
5 'wait', 'wait_for', 'as_completed', 'sleep', 'async', 5 'wait', 'wait_for', 'as_completed', 'sleep', 'async',
6 'gather', 'shield', 'ensure_future', 6 'gather', 'shield', 'ensure_future',
7 ] 7 ]
8 8
9 import concurrent.futures 9 import concurrent.futures
10 import functools 10 import functools
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return; by default all available frames are returned. Its 121 return; by default all available frames are returned. Its
122 meaning differs depending on whether a stack or a traceback is 122 meaning differs depending on whether a stack or a traceback is
123 returned: the newest frames of a stack are returned, but the 123 returned: the newest frames of a stack are returned, but the
124 oldest frames of a traceback are returned. (This matches the 124 oldest frames of a traceback are returned. (This matches the
125 behavior of the traceback module.) 125 behavior of the traceback module.)
126 126
127 For reasons beyond our control, only one stack frame is 127 For reasons beyond our control, only one stack frame is
128 returned for a suspended coroutine. 128 returned for a suspended coroutine.
129 """ 129 """
130 frames = [] 130 frames = []
131 f = self._coro.gi_frame 131 f = (self._coro.gi_frame if hasattr(self._coro, 'gi_frame')
132 else self._coro.cr_frame)
132 if f is not None: 133 if f is not None:
133 while f is not None: 134 while f is not None:
134 if limit is not None: 135 if limit is not None:
135 if limit <= 0: 136 if limit <= 0:
136 break 137 break
137 limit -= 1 138 limit -= 1
138 frames.append(f) 139 frames.append(f)
139 f = f.f_back 140 f = f.f_back
140 frames.reverse() 141 frames.reverse()
141 elif self._exception is not None: 142 elif self._exception is not None:
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 outer.cancel() 670 outer.cancel()
670 else: 671 else:
671 exc = inner.exception() 672 exc = inner.exception()
672 if exc is not None: 673 if exc is not None:
673 outer.set_exception(exc) 674 outer.set_exception(exc)
674 else: 675 else:
675 outer.set_result(inner.result()) 676 outer.set_result(inner.result())
676 677
677 inner.add_done_callback(_done_callback) 678 inner.add_done_callback(_done_callback)
678 return outer 679 return outer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+