From 6560d4587a1e301db5a98e0410213b669bc82a1e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 18 Mar 2024 11:56:22 +0530 Subject: [PATCH] fix: debug stuck process by sending SIGUSR1 It will print stack to stderr. --- frappe/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frappe/__init__.py b/frappe/__init__.py index 97832b2041..59d6e2fb72 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -11,6 +11,7 @@ be used to build database driven apps. Read the documentation: https://frappeframework.com/docs """ import copy +import faulthandler import functools import gc import importlib @@ -18,6 +19,7 @@ import inspect import json import os import re +import signal import traceback import warnings from collections.abc import Callable @@ -304,6 +306,7 @@ def init(site: str, sites_path: str = ".", new_site: bool = False, force=False) if not _qb_patched.get(local.conf.db_type): patch_query_execute() patch_query_aggregation() + _register_fault_handler() setup_module_map(include_all_apps=not (frappe.request or frappe.job or frappe.flags.in_migrate)) @@ -2542,6 +2545,10 @@ def validate_and_sanitize_search_inputs(fn): return wrapper +def _register_fault_handler(): + faulthandler.register(signal.SIGUSR1) + + from frappe.utils.error import log_error if _tune_gc: