mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add a thread dump to support logs
This commit is contained in:
parent
2a6c0ca751
commit
4aad365811
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
@ -251,6 +252,19 @@ class Controller:
|
||||
# Copy crafty logs to archive dir
|
||||
full_log_name = os.path.join(crafty_path, "logs")
|
||||
FileHelpers.copy_dir(os.path.join(self.project_root, "logs"), full_log_name)
|
||||
thread_dump = ""
|
||||
for thread in threading.enumerate():
|
||||
if sys.version_info >= (3, 8):
|
||||
thread_dump += (
|
||||
f"Name: {thread.name}\tIdentifier:"
|
||||
f" {thread.ident}\tTID/PID: {thread.native_id}\n"
|
||||
)
|
||||
else:
|
||||
print(f"Name: {thread.name}\tIdentifier: {thread.ident}")
|
||||
with open(
|
||||
os.path.join(temp_dir, "crafty_thread_dump.txt"), "a", encoding="utf-8"
|
||||
) as f:
|
||||
f.write(thread_dump)
|
||||
self.support_scheduler.add_job(
|
||||
self.log_status,
|
||||
"interval",
|
||||
|
Loading…
Reference in New Issue
Block a user