miki725 / django-gevent-deploy Goto Github PK
View Code? Open in Web Editor NEWHook to manage.py to be able to start gevent WSGI server
Hook to manage.py to be able to start gevent WSGI server
Traceback:
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
583. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
195. if not self.has_permission(request):
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/admin/sites.py" in has_permission
152. return request.user.is_active and request.user.is_staff
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/utils/functional.py" in inner
224. self._setup()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/utils/functional.py" in _setup
357. self._wrapped = self._setupfunc()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in <lambda>
22. request.user = SimpleLazyObject(lambda: get_user(request))
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in get_user
10. request._cached_user = auth.get_user(request)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in get_user
152. user_id = request.session[SESSION_KEY]
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in __getitem__
49. return self._session[key]
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
175. self._session_cache = self.load()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
21. expire_date__gt=timezone.now()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/query.py" in get
351. num = len(clone)
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/query.py" in __len__
122. self._fetch_all()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
966. self._result_cache = list(self.iterator())
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/query.py" in iterator
265. for row in compiler.results_iter():
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
700. for rows in self.execute_sql(MULTI):
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
784. cursor = self.connection.cursor()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/backends/__init__.py" in cursor
163. self.validate_thread_sharing()
File "/Volumes/Data/Users/miki725/.virtualenvs/gevent/lib/python2.7/site-packages/django/db/backends/__init__.py" in validate_thread_sharing
515. % (self.alias, self._thread_ident, thread.get_ident()))
Exception Type: DatabaseError at /admin/auth/user/
Exception Value: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140735171056384 and this is thread id 4440478576.
Using just python manage.py rungevent 0.0.0.0:8009
, I get:
Traceback (most recent call last):
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/baseserver.py", line 159, in _do_read
self.do_handle(*args)
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/baseserver.py", line 130, in do_handle
self._handle(*args)
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 658, in handle
handler.handle()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 184, in handle
result = self.handle_one_request()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 294, in handle_one_request
self.requestline = self.read_requestline()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 287, in read_requestline
return self.rfile.readline(MAX_REQUEST_LINE)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/socket.py", line 392, in recv
self._wait(self._read_event)
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/socket.py", line 298, in _wait
self.hub.wait(watcher)
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/hub.py", line 341, in wait
result = waiter.get()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/hub.py", line 568, in get
return self.hub.switch()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/hub.py", line 330, in switch
switch_out()
File "/home/ubuntu/Envs/web/local/lib/python2.7/site-packages/gevent/hub.py", line 334, in switch_out
raise AssertionError('Impossible to call blocking function in the event loop callback')
AssertionError: Impossible to call blocking function in the event loop callback
((('10.0.0.8', 63542),),
<WSGIServer at 0x7fbb5d406b10 fileno=5 address=0.0.0.0:8009>) failed with AssertionError
Currently the dev server handles serving static files for you. This functionality is turned off when using the gevent WSGI server.
Hendrix for example handles this for you:
https://github.com/hangarunderground/hendrix#serving-static-files
One way to handle this is to run manage.py collectstatic
and then add the following to the urls.py
:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Is there a better way to do this automatically?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.