Many apps require asynchronous execution of functions in a “fire-and-forget” fashion to work optimally. In this scenario, you hand off execution of a function to be Cerebrium’s responsibility, while you as the developer are responsible for ensuring that data is able to leave the function. You can enable your function to execute asynchronously by adding theDocumentation Index
Fetch the complete documentation index at: https://cerebrium-fix-make-entrypoint-docs-explicit.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
async query parameter to your request and setting it to true. This would look something like this:
run_id:
response_grace_period.
This defaults to 15 minutes so max sure to update it to the maximum time your task needs.
In the background, Cerebrium will now run this HTTP request for you.
Your function is still expected to behave in a synchronous manner. That is, it must execute a body of work and return a result once it is done.
If you terminate your function early and return a response while the application is still doing work, the Cerebrium
system will begin to terminate the application. Therefore, you should only return a response once the container
has finished processing the task, and not earlier.
To use async execution effectively, you must ensure that your function exports any relevant data you
need, since you will no longer be able to receive a request. An easy way to achieve this would be to combine
async execution with a specified webhookEndpoint, to have Cerebrium automatically forward the body of
the function response once it has returned:
failure etc.)