forked from mitocw/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to send SIGPROF to an edx-platform process to obtain …
…a memory dump
- Loading branch information
1 parent
03594aa
commit a69c4ef
Showing
5 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters