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
229af4fc
Commit
229af4fc
authored
Dec 21, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19967: Defer the formating of the traceback in asyncio.Future destructor
parent
ba0c8934
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
Lib/asyncio/futures.py
Lib/asyncio/futures.py
+14
-11
No files found.
Lib/asyncio/futures.py
View file @
229af4fc
...
...
@@ -131,8 +131,8 @@ class Future:
_blocking
=
False
# proper use of future (yield vs yield from)
_
traceback
=
Non
e
# Used for Python 3.4 and later
_tb_logger
=
None
# Used for Python 3.3 only
_
log_traceback
=
Fals
e
# Used for Python 3.4 and later
_tb_logger
=
None
# Used for Python 3.3 only
def
__init__
(
self
,
*
,
loop
=
None
):
"""Initialize the future.
...
...
@@ -168,9 +168,13 @@ class Future:
if
_PY34
:
def
__del__
(
self
):
if
self
.
_traceback
is
not
None
:
logger
.
error
(
'Future/Task exception was never retrieved:
\
n
%s'
,
''
.
join
(
self
.
_traceback
))
if
not
self
.
_log_traceback
:
# set_exception() was not called, or result() or exception()
# has consumed the exception
return
exc
=
self
.
_exception
logger
.
error
(
'Future/Task exception was never retrieved:'
,
exc_info
=
(
exc
.
__class__
,
exc
,
exc
.
__traceback__
))
def
cancel
(
self
):
"""Cancel the future and schedule callbacks.
...
...
@@ -224,10 +228,10 @@ class Future:
raise
CancelledError
if
self
.
_state
!=
_FINISHED
:
raise
InvalidStateError
(
'Result is not ready.'
)
self
.
_
traceback
=
Non
e
self
.
_
log_traceback
=
Fals
e
if
self
.
_tb_logger
is
not
None
:
self
.
_tb_logger
.
clear
()
self
.
_tb_logger
=
None
self
.
_tb_logger
=
None
if
self
.
_exception
is
not
None
:
raise
self
.
_exception
return
self
.
_result
...
...
@@ -244,10 +248,10 @@ class Future:
raise
CancelledError
if
self
.
_state
!=
_FINISHED
:
raise
InvalidStateError
(
'Exception is not set.'
)
self
.
_
traceback
=
Non
e
self
.
_
log_traceback
=
Fals
e
if
self
.
_tb_logger
is
not
None
:
self
.
_tb_logger
.
clear
()
self
.
_tb_logger
=
None
self
.
_tb_logger
=
None
return
self
.
_exception
def
add_done_callback
(
self
,
fn
):
...
...
@@ -301,8 +305,7 @@ class Future:
self
.
_state
=
_FINISHED
self
.
_schedule_callbacks
()
if
_PY34
:
self
.
_traceback
=
traceback
.
format_exception
(
exception
.
__class__
,
exception
,
exception
.
__traceback__
)
self
.
_log_traceback
=
True
else
:
self
.
_tb_logger
=
_TracebackLogger
(
exception
)
# Arrange for the logger to be activated after all callbacks
...
...
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