question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: An asyncio.Future, a coroutine or an awaitable is required

See original GitHub issue

Hi

I was trying to run uvicorn + Django channels but i get this error:

2018-08-29 07:35:43 -0500] [9160] [ERROR] Exception in ASGI application
Aug 29 07:35:43 sofia gunicorn[9118]: Traceback (most recent call last):
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 140, in run_asgi
Aug 29 07:35:43 sofia gunicorn[9118]:     result = await asgi(self.asgi_receive, self.asgi_send)
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/channels/sessions.py", line 175, in __call__
Aug 29 07:35:43 sofia gunicorn[9118]:     return await self.inner(receive, self.send)
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/channels/middleware.py", line 41, in coroutine_call
Aug 29 07:35:43 sofia gunicorn[9118]:     await inner_instance(receive, send)
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/channels/consumer.py", line 54, in __call__
Aug 29 07:35:43 sofia gunicorn[9118]:     await await_many_dispatch([receive, self.channel_receive], self.dispatch)
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/channels/utils.py", line 57, in await_many_dispatch
Aug 29 07:35:43 sofia gunicorn[9118]:     await task
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/channels/utils.py", line 49, in await_many_dispatch
Aug 29 07:35:43 sofia gunicorn[9118]:     result = task.result()
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 223, in asgi_receive
Aug 29 07:35:43 sofia gunicorn[9118]:     data = await self.recv()
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/local/lib/python3.6/dist-packages/websockets/protocol.py", line 336, in recv
Aug 29 07:35:43 sofia gunicorn[9118]:     loop=self.loop, return_when=asyncio.FIRST_COMPLETED)
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 311, in wait
Aug 29 07:35:43 sofia gunicorn[9118]:     fs = {ensure_future(f, loop=loop) for f in set(fs)}
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 311, in <setcomp>
Aug 29 07:35:43 sofia gunicorn[9118]:     fs = {ensure_future(f, loop=loop) for f in set(fs)}
Aug 29 07:35:43 sofia gunicorn[9118]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 526, in ensure_future
Aug 29 07:35:43 sofia gunicorn[9118]:     raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
Aug 29 07:35:43 sofia gunicorn[9118]: TypeError: An asyncio.Future, a coroutine or an awaitable is required

django==2.0.7 channels==2.1.3 gunicorn==19.9.0 uvicorn==0.3.2

Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Christophe31commented, Aug 26, 2020

You can pass uvicorn arg to gunicorn by making your own worker like this:

from uvicorn.workers import UvicornWorker

class DjangoUvicornWorker(UvicornWorker):
    CONFIG_KWARGS = {
        "loop": "uvloop",
        "http": "httptools",
        "lifespan": "off",  # lifespan is not handled by django channels for now
        "ws": "wsproto",
    }

Then use this as your --worker-class

2reactions
jamneckcommented, Sep 9, 2019

The bus is fixed installing wsproto and using it with the command --ws wsproto

How did you set --ws wsproto for gunicorn?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: An asyncio.Future, a coroutine or an awaitable is ...
I'm trying to make an asynchronous web scraper using beautifulsoup and aiohttp.This is my initial code to start things.I'm getting a [TypeError: ......
Read more >
nest_asyncio error: TypeError: An asyncio.Future, a coroutine ...
I am getting the a persistent error when loading a class through spyder console. Loading the same class on my windows os does...
Read more >
An asyncio.Future, a coroutine or an awaitable is required in ...
display(df). I get the following error: TypeError: An asyncio.Future, a coroutine or an awaitable is required. I launch the script in Spyder, Anaconda....
Read more >
An asyncio.Future, a coroutine or an awaitable is required
I'm trying to make an asynchronous web scraper using beautifulsoup and aiohttp.This is my initial code to start things.I'm getting a [TypeError: An...
Read more >
Common Mistakes Using Python3 asyncio
1. Introduction · 2. RuntimeWarning: coroutine foo was never awaited · 3. Task was destroyed but it is pending! · 4. Task/Future is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found