Problems with gevent - NotImplementedError gevent is only usable from a single thread

423 views
Skip to first unread message

Milind

unread,
Nov 16, 2012, 7:41:18 AM11/16/12
to mod...@googlegroups.com
I deployed my site with mod_wsgi and Apache. The CSS and the images also come, after proper configuration of httpd.conf
All the links on my first index page work fine, but when I login into my site, it throws an error :

NotImplementedError

gevent is only usable from a single thread

This error does not occur when I serve my site on Django development server.
But as soon as I switch to Apache, this starts coming up consistently. I checked by switching between the two servers.
I also tried changing ports for both Apache and Django. The pattern remains the same.

Am I missing something here??

On Apache 2.4, mod_wsgi 3.4, Python 2.7 on Ubuntu 12.10.

Thanks,
Milind.

Graham Dumpleton

unread,
Nov 16, 2012, 5:53:12 PM11/16/12
to modwsgi
In various configurations mod_wsgi will be multithreaded and they will be real threads not greenlets because they are created at C API using Apache runtime library thread management APIs.

Because of that you would need to be very careful of how you manage any greenlets created by gevent and ensure that they are not shared in any way across request threads. You would need to ensure using thread locals or other means to keep them specific to a mod_wsgi request thread.

You wouldn't have seen an issue with the Django development server because it is single threaded.

Can you explain how you are trying to use gevent coroutines?

Graham


--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/y_cLkgUG49wJ.
To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.

Milind Utsav

unread,
Nov 19, 2012, 3:10:27 AM11/19/12
to mod...@googlegroups.com
I added the lines :
WSGIDaemonProcess site-1 user=ubuntu group=ubuntu processes=5 threads=1
WSGIProcessGroup site-1

And my problem was solved...!

Thanks,
Milind.
--
Milind Utsav,
Software Developer,
Teritree Technologies Pvt. Ltd.
              +91-9742565861

Reply all
Reply to author
Forward
0 new messages