Add the ability to send SIGPROF to an edx-platform process to obtain a memory dump
This commit is contained in:
17
openedx/core/operations.py
Normal file
17
openedx/core/operations.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
import signal
|
||||
import tempfile
|
||||
|
||||
from datetime import datetime
|
||||
from meliae import scanner
|
||||
|
||||
|
||||
def dump_memory(signum, frame):
|
||||
"""Dump memory stats for the current process to a temp directory. Uses the meliae output format."""
|
||||
scanner.dump_all_objects('{}/meliae.{}.{}.dump'.format(tempfile.gettempdir(), datetime.now().isoformat(), os.getpid()))
|
||||
|
||||
def install_memory_dumper(dump_signal=signal.SIGPROF):
|
||||
"""
|
||||
Install a signal handler on `signal` to dump memory stats for the current process.
|
||||
"""
|
||||
signal.signal(dump_signal, dump_memory)
|
||||
Reference in New Issue
Block a user