diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-22 07:49:52 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-22 07:49:52 +0000 |
commit | e8a9d213e4516a7fceead372da13e9b1bc454b4f (patch) | |
tree | b9b4ca1691191ee86f2120fcc086dd9026adbf2f /modules/initialize_util.py | |
parent | a459075d26eecc38d6d58116e38f453450191460 (diff) | |
download | stable-diffusion-webui-gfx803-e8a9d213e4516a7fceead372da13e9b1bc454b4f.tar.gz stable-diffusion-webui-gfx803-e8a9d213e4516a7fceead372da13e9b1bc454b4f.tar.bz2 stable-diffusion-webui-gfx803-e8a9d213e4516a7fceead372da13e9b1bc454b4f.zip |
dump current stack traces when exiting with SIGINT
Diffstat (limited to 'modules/initialize_util.py')
-rw-r--r-- | modules/initialize_util.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/initialize_util.py b/modules/initialize_util.py index d8370576..2894eee4 100644 --- a/modules/initialize_util.py +++ b/modules/initialize_util.py @@ -132,10 +132,29 @@ def get_gradio_auth_creds(): yield cred
+def dumpstacks():
+ import threading
+ import traceback
+
+ id2name = {th.ident: th.name for th in threading.enumerate()}
+ code = []
+ for threadId, stack in sys._current_frames().items():
+ code.append(f"\n# Thread: {id2name.get(threadId, '')}({threadId})")
+ for filename, lineno, name, line in traceback.extract_stack(stack):
+ code.append(f"""File: "{filename}", line {lineno}, in {name}""")
+ if line:
+ code.append(" " + line.strip())
+
+ print("\n".join(code))
+
+
def configure_sigint_handler():
# make the program just exit at ctrl+c without waiting for anything
def sigint_handler(sig, frame):
print(f'Interrupted with signal {sig} in {frame}')
+
+ dumpstacks()
+
os._exit(0)
if not os.environ.get("COVERAGE_RUN"):
|