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.

[BUG] using yield in route

See original GitHub issue

Describe the bug

I am not sure if it is a bug, or a feature request. Perhaps using yield in a route is not intended by fastapi.

To Reproduce

  1. Create a file with:
@app.get("/")
async def root():
    print('hello')
    yield JSONResponse({'some': 'text'})
    print('world')

  1. Open the browser and call the endpoint /.

Expected behaviour

The {‘some’: ‘text’} as json.

Screenshots

But this is what I get.

image

Environment

  • Linux Mint 19
  • Fastapi 0.54.1

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
HuiiBuhcommented, Apr 26, 2020

@tiangolo Just out of interest. Do you consider supporting yield as response?

1reaction
Dustyposacommented, Apr 16, 2020

If you want to do something after send a response. You can try background task

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug Symfony Can use "yield from" only with arrays
Can use "yield from" only with arrays and Traversables If I modify anything in my "Entities" entity then symfony sends me back:.
Read more >
Bug Type - Loomian Legacy Wiki - Fandom
There are currently 24 Loomians that are Bug-type, of which nine are pure and 15 are ... ID, Sprite, Name, Type, Earliest Obtaining...
Read more >
Trade Route Bug
Once I did that, Trade routes started incrementing by 1 again per commercial center (but they don't reset to the correct value).
Read more >
Confirmed from livestream, Poundmakers trade route reverse ...
... Poundmakers trade route reverse yield bug is getting fixed. Cant wait to get back to making crazy pasture city and growing my...
Read more >
Mastering RouterLink
params in the Item component will yield {bar: 'baz'} (along with {id: 1} since the named parameter :id is also defined on that...
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