Execute calls to a Cerebrium app to be run asynchronously
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.)