From 03594aa3f47d2ad5a85060b5dcbe36cfd87b0fcc Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 30 Jan 2015 09:27:08 -0500 Subject: [PATCH 1/2] Upgrade pip --- requirements/edx/base.txt | 1 - requirements/edx/pre.txt | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 96ecd2ae87..9c65b119fb 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -58,7 +58,6 @@ oauthlib==0.6.3 paramiko==1.9.0 path.py==3.0.1 Pillow==2.7.0 -pip>=1.4 polib==1.0.3 pycrypto>=2.6 pygments==2.0.1 diff --git a/requirements/edx/pre.txt b/requirements/edx/pre.txt index 363fb2d247..036f0b1e64 100644 --- a/requirements/edx/pre.txt +++ b/requirements/edx/pre.txt @@ -7,3 +7,6 @@ # Numpy and scipy can't be installed in the same pip run. # Install numpy before other things to help resolve the problem. numpy==1.6.2 + +# Needed to make sure that options in base.txt are allowed +pip==6.0.7 From a69c4efd210d5baeea06d03741253a7e703456ab Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 29 Jan 2015 14:23:29 -0500 Subject: [PATCH 2/2] Add the ability to send SIGPROF to an edx-platform process to obtain a memory dump --- cms/wsgi.py | 4 +++- lms/wsgi.py | 4 +++- openedx/core/operations.py | 17 +++++++++++++++++ requirements/edx/base.txt | 3 +++ requirements/edx/pre.txt | 3 +++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 openedx/core/operations.py diff --git a/cms/wsgi.py b/cms/wsgi.py index af11d8d532..aa760d0782 100644 --- a/cms/wsgi.py +++ b/cms/wsgi.py @@ -6,8 +6,10 @@ defuse_xml_libs() import contracts contracts.disable_all() -import os +import openedx.core.operations +openedx.core.operations.install_memory_dumper() +import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.envs.aws") import cms.startup as startup diff --git a/lms/wsgi.py b/lms/wsgi.py index f47a3851c2..ca49db1f4e 100644 --- a/lms/wsgi.py +++ b/lms/wsgi.py @@ -6,8 +6,10 @@ defuse_xml_libs() import contracts contracts.disable_all() -import os +import openedx.core.operations +openedx.core.operations.install_memory_dumper() +import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws") import lms.startup as startup diff --git a/openedx/core/operations.py b/openedx/core/operations.py new file mode 100644 index 0000000000..363d50c508 --- /dev/null +++ b/openedx/core/operations.py @@ -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) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 9c65b119fb..02b985f1e6 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -50,6 +50,9 @@ lazy==1.1 lxml==3.3.6 mako==0.9.1 Markdown==2.2.1 +--allow-external meliae +--allow-unverified meliae +meliae==0.4.0 mongoengine==0.7.10 networkx==1.7 nltk==2.0.4 diff --git a/requirements/edx/pre.txt b/requirements/edx/pre.txt index 036f0b1e64..d4d3129680 100644 --- a/requirements/edx/pre.txt +++ b/requirements/edx/pre.txt @@ -10,3 +10,6 @@ numpy==1.6.2 # Needed to make sure that options in base.txt are allowed pip==6.0.7 + +# Needed for meliae +Cython==0.21.2