{"action":"closed","issue":{"url":"https://api.github.com/repos/timothycrosley/hug/issues/364","repository_url":"https://api.github.com/repos/timothycrosley/hug","labels_url":"https://api.github.com/repos/timothycrosley/hug/issues/364/labels{/name}","comments_url":"https://api.github.com/repos/timothycrosley/hug/issues/364/comments","events_url":"https://api.github.com/repos/timothycrosley/hug/issues/364/events","html_url":"https://github.com/timothycrosley/hug/issues/364","id":174717114,"number":364,"title":"async support is incompatible with threads","user":{"login":"vortec","id":864772,"avatar_url":"https://avatars2.githubusercontent.com/u/864772?v=3","gravatar_id":"","url":"https://api.github.com/users/vortec","html_url":"https://github.com/vortec","followers_url":"https://api.github.com/users/vortec/followers","following_url":"https://api.github.com/users/vortec/following{/other_user}","gists_url":"https://api.github.com/users/vortec/gists{/gist_id}","starred_url":"https://api.github.com/users/vortec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vortec/subscriptions","organizations_url":"https://api.github.com/users/vortec/orgs","repos_url":"https://api.github.com/users/vortec/repos","events_url":"https://api.github.com/users/vortec/events{/privacy}","received_events_url":"https://api.github.com/users/vortec/received_events","type":"User","site_admin":false},"labels":[{"id":237259883,"url":"https://api.github.com/repos/timothycrosley/hug/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-02T09:25:21Z","updated_at":"2017-05-04T06:57:26Z","closed_at":"2017-05-04T06:57:26Z","body":"A simple app like this:\n\n```\n@hug.get('/ping')\nasync def ping():\n    return 'pong'\n```\n\ndoesn't work with uWSGI and gunicorn threads. It raises this exception once you requested the endpoint via HTTP:\n\n```\n[2016-09-02 11:21:04 +0200] [45145] [ERROR] Error handling request /ping\nTraceback (most recent call last):\n  File \"python3.5/site-packages/gunicorn/workers/gthread.py\", line 283, in handle\n    keepalive = self.handle_request(req, conn)\n  File \"python3.5/site-packages/gunicorn/workers/gthread.py\", line 332, in handle_request\n    respiter = self.wsgi(environ, resp.start_response)\n  File \"python3.5/site-packages/hug/api.py\", line 381, in api_auto_instantiate\n    return module.__hug_wsgi__(*kargs, **kwargs)\n  File \"python3.5/site-packages/falcon/api.py\", line 189, in __call__\n    responder(req, resp, **params)\n  File \"python3.5/site-packages/hug/interface.py\", line 586, in __call__\n    self.render_content(self.call_function(**input_parameters), request, response, **kwargs)\n  File \"python3.5/site-packages/hug/interface.py\", line 530, in call_function\n    return self.interface(**parameters)\n  File \"python3.5/site-packages/hug/interface.py\", line 112, in __call__\n    return asyncio_call(__hug_internal_self._function, *args, **kwargs)\n  File \"python3.5/site-packages/hug/interface.py\", line 51, in asyncio_call\n    loop = asyncio.get_event_loop()\n  File \"/lib/python3.5/asyncio/events.py\", line 589, in get_event_loop\n    return get_event_loop_policy().get_event_loop()\n  File \"/lib/python3.5/asyncio/events.py\", line 535, in get_event_loop\n    % threading.current_thread().name)\nRuntimeError: There is no current event loop in thread 'Thread-4'.`\n```\n\nFurthermore, if you use `gunicorn --processes=2 --threads=1 --preload`, you get this exception:\n\n```\nTraceback (most recent call last):\n  File \"python3.5/site-packages/gunicorn/workers/sync.py\", line 135, in handle\n    self.handle_request(listener, req, client, addr)\n  File \"python3.5/site-packages/gunicorn/workers/sync.py\", line 191, in handle_request\n    six.reraise(*sys.exc_info())\n  File \"python3.5/site-packages/gunicorn/six.py\", line 625, in reraise\n    raise value\n  File \"python3.5/site-packages/gunicorn/workers/sync.py\", line 176, in handle_request\n    respiter = self.wsgi(environ, resp.start_response)\n  File \"python3.5/site-packages/hug/api.py\", line 381, in api_auto_instantiate\n    return module.__hug_wsgi__(*kargs, **kwargs)\n  File \"python3.5/site-packages/falcon/api.py\", line 189, in __call__\n    responder(req, resp, **params)\n  File \"python3.5/site-packages/hug/interface.py\", line 586, in __call__\n    self.render_content(self.call_function(**input_parameters), request, response, **kwargs)\n  File \"python3.5/site-packages/hug/interface.py\", line 530, in call_function\n    return self.interface(**parameters)\n  File \"python3.5/site-packages/hug/interface.py\", line 112, in __call__\n    return asyncio_call(__hug_internal_self._function, *args, **kwargs)\n  File \"python3.5/site-packages/hug/interface.py\", line 53, in asyncio_call\n    loop.run_until_complete(function)\n  File \"/lib/python3.5/asyncio/base_events.py\", line 330, in run_until_complete\n    self.run_forever()\n  File \"/lib/python3.5/asyncio/base_events.py\", line 301, in run_forever\n    self._run_once()\n  File \"/lib/python3.5/asyncio/base_events.py\", line 1162, in _run_once\n    event_list = self._selector.select(timeout)\n  File \"/lib/python3.5/selectors.py\", line 560, in select\n    kev_list = self._kqueue.control(None, max_ev, timeout)\nOSError: [Errno 9] Bad file descriptor\n```\n"}}
{"actor":{"display_login":"timothycrosley"}}