Open clime opened 11 years ago
It's a known issue but apparently not documented anywhere. Sorry about that. The workaround is to run the development server in single-threaded mode:
$ python manage.py runserver --nothreading --noreload
I am leaving this open to update the documentation.
Thanks! That helped. I am getting another exception when accessing http://127.0.0.1:8000/profiler/:
EDIT: It sorted out after I restarted the testserver and python profiling works now!
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/profiler/
Django Version: 1.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'profiler',
'grappelli',
'django.contrib.gis',
'django.contrib.admin',
'django.contrib.admindocs',
'endless_pagination',
'debug_toolbar',
'anycluster',
'web')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'profiler.middleware.ProfilerMiddleware',
'profiler.middleware.StatProfMiddleware',
'middleware.ProfilerMiddleware')
Traceback:
File "/srv/www/envs/cwu/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
92. response = middleware_method(request)
File "/srv/www/envs/cwu/src/django-live-profiler/profiler/middleware.py" in process_request
34. statprof.reset(getattr(settings, 'LIVEPROFILER_STATPROF_FREQUENCY', 100))
File "/srv/www/envs/cwu/lib/python2.7/site-packages/statprof.py" in reset
270. assert state.profile_level == 0, "Can't reset() while statprof is running"
Exception Type: AssertionError at /profiler/
Exception Value: Can't reset() while statprof is running
I'm getting this same error even with --nothreading and --noreload specified. Python 2.7.4, Django 1.5.1, latest django-live-profiler from git commit.
--noreload works for me but is there a permanent solution?
There doesn't appear to be a solution to the threading issue, since statprof
cannot trigger a signal from a child thread.
However, I've updated this library to work on Django 2.2 and fixed a few other issues here, you may find this PR useful: https://github.com/InviteBox/django-live-profiler/pull/28
I am getting the following exception when trying to run my app.
If I remove
'profiler.middleware.StatProfMiddleware',
fromMIDDLEWARE_CLASSES
, the problem disappears but I have installed django-live-profiler specifically for python profiling.I run the test server (./manage.py runserver). Any help, please?