Coder Social home page Coder Social logo

Comments (6)

atereshkin avatar atereshkin commented on August 22, 2024 5

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.

from django-live-profiler.

clime avatar clime commented on August 22, 2024

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

from django-live-profiler.

eressler avatar eressler commented on August 22, 2024

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.

from django-live-profiler.

andrewhodel avatar andrewhodel commented on August 22, 2024

http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Igetexceptions.ValueError:signalonlyworksinmainthreadwhenItrytorunmyTwistedprogramWhatswrong

from django-live-profiler.

tahseen09 avatar tahseen09 commented on August 22, 2024

--noreload works for me but is there a permanent solution?

from django-live-profiler.

pirate avatar pirate commented on August 22, 2024

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: #28

from django-live-profiler.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.