Endpoint
class.
endpoint
on the Endpoint
class. This allows you to use the following methods or instances variables from the Endpoint
class:
run
or synchronous run_sync
method.
Choosing between asynchronous and synchronous execution hinges on your task’s needs and application design.
run_sync
method. This method blocks the execution until the endpoint run is complete or until it times out.
run
method. This method allows you to start an endpoint run and then check its status or wait for its completion at a later time.
asyncio
library for handling concurrent Endpoint calls efficiently. This method embraces Python’s asyncio framework for asynchronous programming, requiring functions to be defined with async and called with await. This approach is inherently non-blocking and is built to handle concurrency efficiently.
"return_aggregate_stream": True
option on the start
method of your Handler. Once enabled, use the stream
method to receive data as it becomes available.
status()
function on the run request to return the status of the Job.
cancel()
function on the run request. You might want to cancel a Job because it’s stuck with a status of IN_QUEUE
or IN_PROGRESS
, or because you no longer need the result.
The following pattern cancels a job given a human interaction, for example pressing Ctrl+C
in the terminal.
This sends a SIGINT
signal to the running Job by catching the KeyboardInterrupt
exception.
cancel()
function and the timeout
argument to cancel the Job after a specified time.
In the previous cancel()
example, the Job is canceled due to an external condition. In this example, you can cancel a running Job that has taken too long to complete.
purge_queue()
function. You can provide the timeout
parameter to specify how long to wait for the server to respond before purging the queue.
purge_queue()
doesn’t affect Jobs in progress.