Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Reproducible Builds
diffoscope
Compare revisions
22aba2285f81092696fb57107041cdb0e3bff69a...0fc439ee035ae9ef657054f8747caf774a5772ee
Commits (4)
Clarify control flow in diffoscope.profiling.
· 3e7491bd
Chris Lamb
authored
Jun 08, 2022
3e7491bd
Clarify in what situations the main "finally" block gets called with respect to TERM handling.
· c26ac469
Chris Lamb
authored
Jun 08, 2022
c26ac469
Emit a warning if/when we are handling a TERM signal.
· d77ff3a3
Chris Lamb
authored
Jun 08, 2022
d77ff3a3
Print profile output if we were called with --profile and we were killed via TERM.
· 0fc439ee
Chris Lamb
authored
Jun 08, 2022
0fc439ee
Hide whitespace changes
Inline
Side-by-side
diffoscope/main.py
View file @
0fc439ee
...
...
@@ -726,7 +726,10 @@ def run_diffoscope(parsed_args):
def
sigterm_handler
(
signo
,
stack_frame
):
logger
.
warning
(
"Received TERM signal; cleaning up temp files..."
)
clean_all_temp_files
()
ProfileManager
().
finish
()
logger
.
warning
(
"Exiting..."
)
os
.
_exit
(
2
)
...
...
@@ -781,6 +784,9 @@ def main(args=None):
pdb
.
post_mortem
()
sys
.
exit
(
2
)
finally
:
# Note that this is block is not called if the sigterm_handler method
# is a) called, and b) executes successfully.
# Helps our tests run more predictably - some of them call main()
# which sets Config() values.
Config
().
reset
()
...
...
diffoscope/profiling.py
View file @
0fc439ee
...
...
@@ -60,16 +60,25 @@ class ProfileManager:
self
.
data
[
namespace
][
key
][
"time"
]
+=
time
.
time
()
-
start
self
.
data
[
namespace
][
key
][
"count"
]
+=
1
def
finish
(
self
,
parsed_args
):
def
finish
(
self
,
parsed_args
=
None
):
from
.presenters.utils
import
make_printer
# We are being called in the TERM handler so we don't have access to
# parsed_args. Print the profiling output to stderr if we have been
# collecting it.
if
parsed_args
is
None
:
if
_ENABLED
:
self
.
output
(
lambda
x
:
print
(
x
,
file
=
sys
.
stderr
))
return
# Include profiling in --debug output if --profile is not set.
if
parsed_args
.
profile_output
is
None
:
with
setup_logging
(
parsed_args
.
debug
,
None
)
as
logger
:
self
.
output
(
lambda
x
:
logger
.
debug
(
x
.
strip
(
"
\n
"
)))
else
:
with
make_printer
(
parsed_args
.
profile_output
)
as
fn
:
self
.
output
(
fn
)
return
with
make_printer
(
parsed_args
.
profile_output
)
as
fn
:
self
.
output
(
fn
)
def
output
(
self
,
print_fn
):
title
=
"# Profiling output for: {}"
.
format
(
" "
.
join
(
sys
.
argv
))
...
...