mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 11:45:58 +08:00
Fix:signal.SIGUSR1 and signal.SIGUSR2 can't use in window. so don't bind signal.SIGUSR1 and signal.SIGUSR2 in the windows env (#5941)
### What problem does this PR solve? Fix:signal.SIGUSR1 and signal.SIGUSR2 can't use in window. so don't bind signal.SIGUSR1 and signal.SIGUSR2 in the windows env ### Type of change - [✓ ] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): Co-authored-by: tangyu <1@1.com>
This commit is contained in:
parent
caecaa7562
commit
1c663b32b9
@ -40,7 +40,6 @@ from io import BytesIO
|
|||||||
from multiprocessing.context import TimeoutError
|
from multiprocessing.context import TimeoutError
|
||||||
from timeit import default_timer as timer
|
from timeit import default_timer as timer
|
||||||
import tracemalloc
|
import tracemalloc
|
||||||
import resource
|
|
||||||
import signal
|
import signal
|
||||||
import trio
|
import trio
|
||||||
import exceptiongroup
|
import exceptiongroup
|
||||||
@ -117,6 +116,12 @@ def start_tracemalloc_and_snapshot(signum, frame):
|
|||||||
snapshot = tracemalloc.take_snapshot()
|
snapshot = tracemalloc.take_snapshot()
|
||||||
snapshot.dump(snapshot_file)
|
snapshot.dump(snapshot_file)
|
||||||
current, peak = tracemalloc.get_traced_memory()
|
current, peak = tracemalloc.get_traced_memory()
|
||||||
|
if sys.platform == "win32":
|
||||||
|
import psutil
|
||||||
|
process = psutil.Process()
|
||||||
|
max_rss = process.memory_info().rss / 1024
|
||||||
|
else:
|
||||||
|
import resource
|
||||||
max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
||||||
logging.info(f"taken snapshot {snapshot_file}. max RSS={max_rss / 1000:.2f} MB, current memory usage: {current / 10**6:.2f} MB, Peak memory usage: {peak / 10**6:.2f} MB")
|
logging.info(f"taken snapshot {snapshot_file}. max RSS={max_rss / 1000:.2f} MB, current memory usage: {current / 10**6:.2f} MB, Peak memory usage: {peak / 10**6:.2f} MB")
|
||||||
|
|
||||||
@ -644,6 +649,7 @@ async def main():
|
|||||||
logging.info(f'TaskExecutor: RAGFlow version: {get_ragflow_version()}')
|
logging.info(f'TaskExecutor: RAGFlow version: {get_ragflow_version()}')
|
||||||
settings.init_settings()
|
settings.init_settings()
|
||||||
print_rag_settings()
|
print_rag_settings()
|
||||||
|
if sys.platform != "win32":
|
||||||
signal.signal(signal.SIGUSR1, start_tracemalloc_and_snapshot)
|
signal.signal(signal.SIGUSR1, start_tracemalloc_and_snapshot)
|
||||||
signal.signal(signal.SIGUSR2, stop_tracemalloc)
|
signal.signal(signal.SIGUSR2, stop_tracemalloc)
|
||||||
TRACE_MALLOC_ENABLED = int(os.environ.get('TRACE_MALLOC_ENABLED', "0"))
|
TRACE_MALLOC_ENABLED = int(os.environ.get('TRACE_MALLOC_ENABLED', "0"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user