Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
0bfbabc2
"git@developer.sourcefind.cn:OpenDAS/lmdeploy.git" did not exist on "7f943a26b69b1e8f80aecb0a660b15eb5719b7b5"
Unverified
Commit
0bfbabc2
authored
Oct 12, 2022
by
Philip Meier
Committed by
GitHub
Oct 12, 2022
Browse files
cache traceback together with exceptions (#6748)
parent
11a2eeda
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
test/common_utils.py
test/common_utils.py
+8
-5
No files found.
test/common_utils.py
View file @
0bfbabc2
...
@@ -210,7 +210,7 @@ def cache(fn):
...
@@ -210,7 +210,7 @@ def cache(fn):
"""
"""
sentinel
=
object
()
sentinel
=
object
()
out_cache
=
{}
out_cache
=
{}
exc_cache
=
{}
exc_
tb_
cache
=
{}
@
functools
.
wraps
(
fn
)
@
functools
.
wraps
(
fn
)
def
wrapper
(
*
args
,
**
kwargs
):
def
wrapper
(
*
args
,
**
kwargs
):
...
@@ -220,14 +220,17 @@ def cache(fn):
...
@@ -220,14 +220,17 @@ def cache(fn):
if
out
is
not
sentinel
:
if
out
is
not
sentinel
:
return
out
return
out
exc
=
exc_cache
.
get
(
key
,
sentinel
)
exc
_tb
=
exc_
tb_
cache
.
get
(
key
,
sentinel
)
if
exc
is
not
sentinel
:
if
exc
_tb
is
not
sentinel
:
raise
exc
raise
exc
_tb
[
0
].
with_traceback
(
exc_tb
[
1
])
try
:
try
:
out
=
fn
(
*
args
,
**
kwargs
)
out
=
fn
(
*
args
,
**
kwargs
)
except
Exception
as
exc
:
except
Exception
as
exc
:
exc_cache
[
key
]
=
exc
# We need to cache the traceback here as well. Otherwise, each re-raise will add the internal pytest
# traceback frames anew, but they will only be removed once. Thus, the traceback will be ginormous hiding
# the actual information in the noise. See https://github.com/pytest-dev/pytest/issues/10363 for details.
exc_tb_cache
[
key
]
=
exc
,
exc
.
__traceback__
raise
exc
raise
exc
out_cache
[
key
]
=
out
out_cache
[
key
]
=
out
...
...
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