Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-121468: Show asyncio information in pdb#124367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
5c52a71a51ba04ae16c8b490a6d9297a684dcb96df9c66d9bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -79,6 +79,7 @@ | ||
| import codeop | ||
| import pprint | ||
| import signal | ||
| import asyncio | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. asyncio will be used as long as pdb is used. Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. You're right. I didn't realize that at the time | ||
| import inspect | ||
| import textwrap | ||
| import tokenize | ||
| @@ -363,6 +364,8 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, | ||
| self._chained_exceptions = tuple() | ||
| self._chained_exception_index = 0 | ||
| self._current_task = None | ||
| def set_trace(self, frame=None, *, commands=None): | ||
| Pdb._last_pdb_instance = self | ||
| if frame is None: | ||
| @@ -405,7 +408,8 @@ def setup(self, f, tb): | ||
| tb = tb.tb_next | ||
| self.curframe = self.stack[self.curindex][0] | ||
| self.set_convenience_variable(self.curframe, '_frame', self.curframe) | ||
| if self._current_task: | ||
| self.set_convenience_variable(self.curframe, '_asynctask', self._current_task) | ||
| self._save_initial_file_mtime(self.curframe) | ||
| if self._chained_exceptions: | ||
| @@ -616,6 +620,13 @@ def _hold_exceptions(self, exceptions): | ||
| self._chained_exceptions = tuple() | ||
| self._chained_exception_index = 0 | ||
| def _get_asyncio_task(self): | ||
| try: | ||
| task = asyncio.current_task() | ||
| except RuntimeError: | ||
| task = None | ||
| return task | ||
| def interaction(self, frame, tb_or_exc): | ||
| # Restore the previous signal handler at the Pdb prompt. | ||
| if Pdb._previous_sigint_handler: | ||
| @@ -626,6 +637,8 @@ def interaction(self, frame, tb_or_exc): | ||
| else: | ||
| Pdb._previous_sigint_handler = None | ||
| self._current_task = self._get_asyncio_task() | ||
| _chained_exceptions, tb = self._get_tb_and_exceptions(tb_or_exc) | ||
| if isinstance(tb_or_exc, BaseException): | ||
| assert tb is not None, "main exception must have a traceback" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ``$_asynctask`` is added as a :mod:`pdb` convenience variable to | ||
| access the current asyncio task if applicable. |
Uh oh!
There was an error while loading.Please reload this page.