Serverless worker doesn't run asynchronously until I request its status in local development
I'm following the docs and created a verey simple handler.py with the following:
import runpoddef handler(event): """ This is a sample handler function that echoes the input and adds a greeting. """ try: # Extract the prompt from the input prompt = event["input"]["prompt"] print (f"Prompt: {prompt}") result = f"Hello! You said: {prompt}" # Return the result return {"output": result} except Exception as e: # If there's an error, return it return {"error": str(e)}# Start the serverless functionrunpod.serverless.start({"handler": handler})
import runpoddef handler(event): """ This is a sample handler function that echoes the input and adds a greeting. """ try: # Extract the prompt from the input prompt = event["input"]["prompt"] print (f"Prompt: {prompt}") result = f"Hello! You said: {prompt}" # Return the result return {"output": result} except Exception as e: # If there's an error, return it return {"error": str(e)}# Start the serverless functionrunpod.serverless.start({"handler": handler})
`
This is running inside a Docker container with a custom Dockerfile and executed with
--- Starting Serverless Worker | Version 1.6.2 ---INFO | Starting API server.DEBUG | Not deployed on RunPod serverless, pings will not be sent. INFO: Started server process [1] INFO: Waiting for application startup.INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
--- Starting Serverless Worker | Version 1.6.2 ---INFO | Starting API server.DEBUG | Not deployed on RunPod serverless, pings will not be sent. INFO: Started server process [1] INFO: Waiting for application startup.INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
But when I POST localhost:8000/run with the expected prompt input, I get a id back saying the job is in progress, but nothing shows on the container logs. It doesn't run until I call /status/jobId. Only then it runs.
Is this the expected behaviour? If so, why?
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
R
Runpod
We're a community of enthusiasts, engineers, and enterprises, all sharing insights on AI, Machine Learning and GPUs!