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:
`
This is running inside a Docker container with a custom Dockerfile and executed with
The local server starts:
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?
8 Replies
Have you tried testing your handler offline by doing the following? It will map a local version of test_input.json inside your application.
This will process your test_input.json through your handler locally. Without having to run Uvicorn at all.
In your Dockerfile you can start your handler like this:
I have not, but anyway it should work well by running a local uvicorn server.
Can you share your Dockerfile?
Are you doing something like this?
You might get more info by entering your image with a bash shell and then trying to load the ./handler from there.
Yes, as I said, the webserver works fine, I can hit the endpoints from my local machine. The jobs won't simply start if I call /run unless I request the status afterwards.
If I do /runsync, they do start immediately.
My Dockerfile ends with
But on development I'm launching it from a compose file where I override the command with
I would still use -u in dev to prevent buffering but everything looks good.
I'm having the same problem, @EMPZ did you find a solution to this?
Nope, I just do /runSync when testing locally.
This is the expected behavior. The asynchronous /run endpoint requires communication with our system, so it can’t be tested locally. For local testing, use the /runSync endpoint instead. I’ll have the documentation team update this. Sorry for the confusion.