RunpodR
Runpod2y ago
4 replies
abtx

How do indicated job status in a handler?

For example in https://docs.runpod.io/serverless/workers/handlers/handler-async
import runpod
import asyncio


async def async_generator_handler(job):
    for i in range(5):
        # Generate an asynchronous output token
        output = f"Generated async token output {i}"
        yield output

        # Simulate an asynchronous task, such as processing time for a large language model
        await asyncio.sleep(1)


# Configure and start the RunPod serverless function
runpod.serverless.start(
    {
        "handler": async_generator_handler,  # Required: Specify the async handler
        "return_aggregate_stream": True,  # Optional: Aggregate results are accessible via /run endpoint
    }
)


Dopes the job status automatically becomes "COMPLETED" after async_generator_handler returns? In general how do you update the status of the job in runpod python sdk?

What I am trying to achieve is to use a single machine at a time for training purposes. I am not sure 1 hour long POST request is a good idea. How should this be done?
RunPod supports the use of asynchronous handlers, enabling efficient handling of tasks that benefit from non-blocking operations. This feature is particularly useful for tasks like processing large datasets, interacting with APIs, or handling I/O-bound operations.
Asynchronous Handler | RunPod Documentation
Was this page helpful?