Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UvicornWorker 'auto' loop and http implementations don't work on Linux without extras installed #816

Closed
2 tasks done
mdgilene opened this issue Oct 13, 2020 · 2 comments · Fixed by #901
Closed
2 tasks done

Comments

@mdgilene
Copy link

mdgilene commented Oct 13, 2020

Checklist

  • The bug is reproducible against the latest release and/or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

After #666 , uvloop and and httptools are no longer installed unless you specify to install the 'standard' extra. Because of this when running with loop='auto' and http='auto' the application fails to start due to 'uvloop' and 'httptools' being selected. NOTE: This only happens when running the uvicorn.workers.UvicornWorker through something like Gunicorn.

To reproduce

pip install uvicorn gunicorn
#main.py
async def app(scope, receive, send):
    assert scope['type'] == 'http'

    await send({
        'type': 'http.response.start',
        'status': 200,
        'headers': [
            [b'content-type', b'text/plain'],
        ],
    })
    await send({
        'type': 'http.response.body',
        'body': b'Hello, world!',
    })
gunicorn -k uvicorn.workers.UvicornWorker main:app

Expected behavior

'auto' should pick 'asyncio' and 'h11' for their respective settings on Linux if the 'standard' extra is not installed.

Actual behavior

Application starts up but immediately throws ModuleNotFoundError: No module named 'uvloop'. If you install uvloop it then complains about not finding httptools. After installing both, no more issues occur.

Debugging material

Environment

  • Running uvicorn 0.12.1 with CPython 3.7.6 on Linux

Additional context

@euri10
Copy link
Member

euri10 commented Oct 31, 2020

Yep, we should be selecting good defaults

@florimondmanca
Copy link
Member

florimondmanca commented Dec 29, 2020

For anyone passing by a looking for a workaround…

https://www.uvicorn.org/deployment/#gunicorn

# myproject/workers.py
class MyUvicornWorker(UvicornWorker):
    CONFIG_KWARGS = {"loop": "auto", "http": "auto"}
$ gunicorn -w myproject.workers.MyUvicornWorker app:app

See #266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants