|
# But now we get a threading error: |
|
|
|
$ ./concurrent_aiohttp_app.py & |
|
[1] 6314 |
|
* Serving Flask app "concurrent_aiohttp_app" (lazy loading) |
|
* Environment: production |
|
WARNING: This is a development server. Do not use it in a production deployment. |
|
Use a production WSGI server instead. |
|
* Debug mode: off |
|
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) |
|
|
|
$ curl localhost:5000 |
|
[2019-08-09 12:37:33,276] ERROR in app: Exception on / [GET] |
|
Traceback (most recent call last): |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app |
|
response = self.full_dispatch_request() |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request |
|
rv = self.handle_user_exception(e) |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception |
|
reraise(exc_type, exc_value, tb) |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise |
|
raise value |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request |
|
rv = self.dispatch_request() |
|
File "/home/robin/Projects/canonicalwebteam.blog/concurrentcy_env/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request |
|
return self.view_functions[rule.endpoint](**req.view_args) |
|
File "./concurrent_aiohttp_app.py", line 47, in index |
|
loop = asyncio.get_event_loop() |
|
File "/usr/lib/python3.6/asyncio/events.py", line 694, in get_event_loop |
|
return get_event_loop_policy().get_event_loop() |
|
File "/usr/lib/python3.6/asyncio/events.py", line 602, in get_event_loop |
|
% threading.current_thread().name) |
|
RuntimeError: There is no current event loop in thread 'Thread-1'. |
|
127.0.0.1 - - [09/Aug/2019 12:37:33] "GET / HTTP/1.1" 500 - |
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
|
<title>500 Internal Server Error</title> |
|
<h1>Internal Server Error</h1> |
|
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p> |