Replies: 2 comments 3 replies
-
|
Your GCS bucket upload is a blocking call, which is causing the server to freeze while it uploads. You should wrap the upload function with import asyncio
# 3.9+
await asyncio.to_thread(
blob.upload_from_string,
data=datasets,
content_type="application/json",
)
# 3.8
from functools import partial
loop = asyncio.get_running_loop()
await loop.run_in_executor(None, partial(
blob.upload_from_string,
data=datasets,
content_type="application/json",
))See the google-cloud-storage samples. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
I updated the version to 0.111.0 and this is fixed |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I have this endpoint as a webhook for Apify crawler to callback when a crawl run job is finished.
I found a weird thing about this:
If I trigger this endpoint from browser, which is the fastapi api docs, the request will wait for the background task to finish and return the status code.
If I trigger the endpoint using a curl, it can return immediately and run the background task in the background.
Operating System
Linux, macOS
Operating System Details
I've observed this in our server which is running on cloud run on linux, I can reproduce this very easily in my macos
FastAPI Version
0.106.0
Pydantic Version
2.7.2
Python Version
Python 3.11.9
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions