I've been having some very weird problems. Yesterday I updated my master branch on a project and after that, when I tried to do manage.py runserver the runserver wouldn't serve any page. I had to ctrl + c to exit the server and I would later receive this message.
Exception happened during processing of request from ('127.0.0.1', 53975)
Unhandled exception in thread started by <function inner_run at 0x2ec8488>
Traceback (most recent call last):
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 60, in inner_run
run(addr, int(port), handler)
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 721, in run
httpd.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 227, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 286, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 342, in handle_error
import traceback
ImportError: No module named traceback
I found out by experimentation that erasing the database(sqlite) and recreating it with syncdb and migrate removed the issue, but once I add something to the models via the admin page, I would get the same error again, no pages would be served.
I also noticed that when this was going on, python starting to occupy around 40-60% of my CPU and RAM. I later noticed on the project folder, where database.db is located, a database.db-journal file would be created every 2-3 seconds, get deleted and then reappear. Googling didn't bring me any results so I am laying my hands on SO wisdom. Thanks.
I can see you are running in a virtual enviroment. It's possible that it became corrupted while downloading. I would recreate it from scratch.
Also, check in that enviroment shell if you can import traceback and check outside the enviroment too. It may give you some clues.
disclaimer: this answer is 90% intuition, sorry :/
A couple months late but anyway, here is what my problem was:
A django app was messing up and getting stuck in a bug. I believe it was Django Cache Bot.
Cheers.
Related
Before I begin, let me give the disclaimer that I'm very new at this sort of thing, that my explanation may not be too coherent, and I have no ability to separate what might and might not be important.
I'd like to run psiTurk. But because psiturk doesn't work on Windows, I'm using Openshift to run Python, with psiturk inside of that. I've gotten Openshift working using PuTTY, and have gotten as far as launching the psiTurk shell. But even when I enter the command to turn the server on, the server remains off with the following error message.
[psiTurk server:off mode:sdbx #HITs:0]$ server on
Experiment server launching...
Now serving on myurl.rhcloud.com
Traceback (most recent call last):
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/cmd2.py", line 789, in onecmd_plus_hooks
stop = self.postcmd(stop, statement)
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/psiturk_shell.py", line 205, in postcmd
self.color_prompt()
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/psiturk_shell.py", line 571, in color_prompt
server_status = self.server.is_server_running()
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/experiment_server_controller.py", line 144, in is_server_running
psiturk_exp_ports = [process[0].laddr[1] for process in [psutil.Process(int(pid)).get_connections() for pid in output]]
AttributeError: 'Process' object has no attribute 'get_connections'
'Process' object has no attribute 'get_connections'
Any help would be much appreciated.
Seems like standard pip install psiturk installs a version of the psutil library that's not compatible with psiturk. What worked for me was installing directly from git:
pip install git+git://github.com/NYUCCL/psiTurk.git#master
See this PR for details: https://github.com/NYUCCL/psiTurk/pull/192
Also, it's best to make a virtualenv to avoid problems with already-installed packages.
I have a celery task that is calling a django management command using call_command and that management command uses the python logging framework to create a TimedRotatingFileHandler.
On a windows test station, I am getting the following stack trace which seems to show that the celery tasks are still holding the log file handle open after they have completed:
Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 77, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.py", line 350, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
Logged from file myCommand.py, line XX
Is this a known issue and if so is there a method for getting around it? (I have tried googling but could not find anything relevant).
i have web app that i have developed using bottle micro framework.
However it crash a lot and all of them suddenly without any action ( without using the web app) . So i have reviewed the logs file and find the following errors (i have no idea what the causation of these errors):
Traceback (most recent call last):
File "/home/hamoud/lib/python2.7/bottle.py", line 2699, in run
server.run(app)
File "/home/hamoud/lib/python2.7/bottle.py", line 2385, in run
srv = make_server(self.host, self.port, handler, **self.options)
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 144, in make_server
server = server_class((host, port), handler_class)
File "/usr/local/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
HTTPServer.server_bind(self)
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/local/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/usr/local/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: 'int' object is not callable
and
Traceback (most recent call last):
File "interface.py", line 29, in <module>
run(host="localhost", port=32471, reloader=True, debug=True)
File "/home/hamoud/lib/python2.7/bottle.py", line 2657, in run
os.utime(lockfile, None) # I am alive!
OSError: [Errno 2] No such file or directory: '/tmp/bottle.gQmJc8.lock'
However the second error doesn't crash the application ( application would continue working ) but for the first one it's require manual work ( run the app again ).
i could schedule task using cron job to run the application when it's crash. but i'd like to know what's the problem in my app.
A few ideas come to mind:
Could there be another program on your machine (e.g., a cron job) that is deleting files from /tmp?
Are you using the latest version of Bottle? (From the line number in your stacktrace, it looks like you might not be.)
If nothing else works, try running without reloader=True (or use reloader=False). I looked at the Bottle code, and that change should at least work around the problem, even though we don't know the cause (yet).
Hope that helps.
At work our host has recently configured our server to run multiple Django projects side-by-side, but something is not quite right. There are two main problems.
Changes do not immediately go into effect. When a site is first deployed (or changed), there will be a period of latency of a couple hours. This usually means incessant 500 errors.
Once everything settles down, the sites work some of the time, but they will randomly break. They first said there were no error messages, but they finally gave me permissions to check the logfiles. It seems to be arbitrarily loading different parts of the different settings files all willy-nilly. In the traceback below, a request is made from URL 1, then the server looks in the directory for URL 2 and tries to load the settings module defined in the wsgi.py for URL 3. But like I said, this doesn't happen every time. Sometimes the sites are loaded correctly.
I have tested these projects on my own host and everything works as expected, but I don't have permissions at the host here to check the exact configurations for httpd.conf and other various necessary things. I also don't have enough experience with apache to guess blindly as to what the problem is, so I'm at a loss here. What are some specific configuration questions I should be asking?
Thanks in advance.
mod_wsgi (pid=####): Exception occurred processing WSGI script '/srv/www/**<url-project 1>**/wsgi.py'.
Traceback (most recent call last):
File "/srv/www/**<url-project 2>**/.local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/srv/www/**<url-project 2>**/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/srv/www/**<url-project 2>**/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/srv/www/**<url-project 2>**/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "/srv/www/**<url-project 2>**/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings '**<url-project 3>**.settings.production' (Is it on sys.path?): No module named **<url-project 3**>.settings.production
Make sure you read:
http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html
Do not use os.environ.setdefault() in the WSGI script file as is now generated by Django. Change it os.environ[…] instead.
Graham's answer was helpful. To anyone else having the same problem, I'd also like to point out the section on WSGIApplicationGroup that says each wsgi application should be run on it's own python sub-interpreter.
more info here: http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIApplicationGroup.html
I'm trying to create a virtualenv with the following command:
$ virtualenv env --distribute
and I am getting the following message:
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.8.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1054, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 655, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/nigelra/Thero...blog/venv/bin/python -x /Users/nigelra/Thero...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2
I'm not particularly adept at reading OSX error messages. Would someone be willing to lend their knowledge to solve this problem?
For anyone else who gets error code 2 in the future here is how I dealt with it.
I never figured out which problem made the fix (there were a lot of problems) but I can outline the steps I took to cleaning up my computer.
I followed this guide to setting up my Python environment "right" http://docs.python-guide.org/en/latest/starting/install/osx/
I encounter a ton of errors when I did $ brew doctor
I laboriously got rid of every warning and error using google as my guide.
Many of the folder permissions had to be changed.
Eventually I was able to set up a virtualenv after a re installation of most everything.
Hope this helps anyone who encounters the same mess I did.