{"action":"created","issue":{"url":"https://api.github.com/repos/unbit/uwsgi/issues/853","labels_url":"https://api.github.com/repos/unbit/uwsgi/issues/853/labels{/name}","comments_url":"https://api.github.com/repos/unbit/uwsgi/issues/853/comments","events_url":"https://api.github.com/repos/unbit/uwsgi/issues/853/events","html_url":"https://github.com/unbit/uwsgi/issues/853","id":58749020,"number":853,"title":"PyPy + Django + gevent loop engine","user":{"login":"dmk23","id":1828444,"avatar_url":"https://avatars.githubusercontent.com/u/1828444?v=3","gravatar_id":"","url":"https://api.github.com/users/dmk23","html_url":"https://github.com/dmk23","followers_url":"https://api.github.com/users/dmk23/followers","following_url":"https://api.github.com/users/dmk23/following{/other_user}","gists_url":"https://api.github.com/users/dmk23/gists{/gist_id}","starred_url":"https://api.github.com/users/dmk23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmk23/subscriptions","organizations_url":"https://api.github.com/users/dmk23/orgs","repos_url":"https://api.github.com/users/dmk23/repos","events_url":"https://api.github.com/users/dmk23/events{/privacy}","received_events_url":"https://api.github.com/users/dmk23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-24T14:52:57Z","updated_at":"2015-02-26T09:36:49Z","closed_at":null,"body":"I am trying to deploy the configuration in the headline and having no luck.\r\n\r\nAs a starting point, I am using the working configuration on CPython and just replacing virtualenv with the one created under PyPy (with uWSGI executable installed via pip on that virtualenv)\r\n\r\nThis configuration fails in multiple ways, specifically:\r\n\r\n1. First of all gevent loop engine does not load and if strict = True logs ```[strict-mode] unknown config directive: gevent```. I was expecting gevent support to be built under pip\r\n\r\n2. With strict turned off, the Django app fails to load ```*** no app loaded. going in full dynamic mode ***``` . Here I was expecting for PyPy virtualenv to honor the same options as CPython\r\n\r\n3. I did look up the options for PyPy module and tried ```pypy-wsgi = django.core.handlers.wsgi:WSGIHandler()``` resulting in the following error:\r\n\r\n```\r\nFrom cffi callback <function uwsgi_pypy_loader at 0x00007f2f93ad6f98>:\r\nTraceback (most recent call last):\r\n  File \"c callback\", line 304, in uwsgi_pypy_loader\r\nAttributeError: 'module' object has no attribute 'WSGIHandler()'\r\n*** no app loaded. going in full dynamic mode ***\r\n```\r\n\r\nAt this point I am not quite sure how to proceed. I find it counter-intuitive that it is not possible to simply swap the virtualenv and preserve the same options and behaviors.\r\n\r\nIn any case would appreciate help figuring out the proper configuration. At the moment the docs are silent on compatibility of PyPy with Django, Gevent or any other plugins / apps."},"comment":{"url":"https://api.github.com/repos/unbit/uwsgi/issues/comments/76147990","html_url":"https://github.com/unbit/uwsgi/issues/853#issuecomment-76147990","issue_url":"https://api.github.com/repos/unbit/uwsgi/issues/853","id":76147990,"user":{"login":"dmk23","id":1828444,"avatar_url":"https://avatars.githubusercontent.com/u/1828444?v=3","gravatar_id":"","url":"https://api.github.com/users/dmk23","html_url":"https://github.com/dmk23","followers_url":"https://api.github.com/users/dmk23/followers","following_url":"https://api.github.com/users/dmk23/following{/other_user}","gists_url":"https://api.github.com/users/dmk23/gists{/gist_id}","starred_url":"https://api.github.com/users/dmk23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmk23/subscriptions","organizations_url":"https://api.github.com/users/dmk23/orgs","repos_url":"https://api.github.com/users/dmk23/repos","events_url":"https://api.github.com/users/dmk23/events{/privacy}","received_events_url":"https://api.github.com/users/dmk23/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T09:36:49Z","updated_at":"2015-02-26T09:36:49Z","body":"Thanks. In my case I'd say Gevent would be more important than PyPy. So I am switching back to CPython and continuing some rigorous testing, with a few new issues\r\n\r\n```\r\nstrict = True\r\ngevent = 100\r\ngevent-monkey-patch = True\r\n#gevent-early-monkey-patch = True\r\ngevent-wait-for-hub = True\r\nprocesses = 2\r\nthreads = 4\r\n```\r\n\r\nHere are the problems with the above config:\r\n\r\n1. Under \"strict\" uWSGI 2.0.9 does not recognize gevent early monkey patch option, so I got it commented out. Are the docs for this option obsolete or it is due in the next release?\r\n2. If I try to reload my page a few times, under Django DEBUG= True, I get the following error. I was under impression that monkey.patch_all() should make MySQLdb just work:\r\n\r\n   ```\r\n   DatabaseWrapper objects created in a thread can only be used in that same thread. \r\n   The object with alias 'default' was created in thread id 139750555608720 and\r\n   this is thread id 139750339108048.\r\n   ```\r\n\r\n3. If I turn off monkey patch in uwsgi.ini file and instead put monkey.patch_all() into Django settings.py I get the same error.\r\n4. I added some \"print\" statements into settings.py and saw that they only get triggered when a new worker gets a request, not when master loads. Isn't it supposed to load once by master?\r\n5. As another experiment I've added the code below before monkey patch code in settings.py. This in turn caused the second page load to simply hang.\r\n\r\n    ```\r\n    if 'threading' in sys.modules:\r\n        del sys.modules['threading']\r\n    ```\r\nWould appreciate any help sorting out what is going wrong here... Have you tested monkey-patched Django/ Gevent with MySQL driver ? Did anything like this come up?"}}