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

Update documentation for background tasks examples (and maybe other examples as well) #89

Closed
jpmelos opened this Issue Jan 5, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@jpmelos
Copy link

jpmelos commented Jan 5, 2019

The documentation should use the new API for @api.route and @view. It currently uses an example in Creating a background task that violates that:

from asyncio import sleep

@api.route('/orders', methods=['post'])
async def create_order(req, res):
    @res.background
    def send_confirmation():
        # TODO: send an email here
        await sleep(1)

    res.status_code = 201

I guess it should be:

from asyncio import sleep

@api.route('/orders')
@view(methods=['post'])
async def create_order(req, res):
    @res.background
    def send_confirmation():
        # TODO: send an email here
        await sleep(1)

    res.status_code = 201

As explained in Specifying HTTP methods.

Is this correct? There might be other API mistakes in the documentation.

@florimondmanca

This comment has been minimized.

Copy link
Member

florimondmanca commented Jan 5, 2019

Thanks for spotting this! This is indeed an artifact from the old API that should have been updated.

@florimondmanca

This comment has been minimized.

Copy link
Member

florimondmanca commented Jan 5, 2019

Done — I've fixed the background tasks examples, and this also had an occurrence in the Responses section. Thanks again for reporting this!

https://bocadilloproject.github.io/guides/http/background-tasks.html#how-do-background-tasks-work

@florimondmanca florimondmanca added this to the v0.9 milestone Jan 13, 2019

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