superlinear-ai / poetry-cookiecutter

🍪 Poetry Cookiecutter is a modern Cookiecutter template for scaffolding Python packages and apps
GNU Affero General Public License v3.0
242 stars 34 forks source link

Add missing `use_exec` to serve the API #203

Open lsorber opened 10 months ago

lsorber commented 10 months ago

We should be exec'ing that process, but it seems that Poe the Poet does not support this for shell tasks: https://poethepoet.natn.io/tasks/task_types/shell.html#available-task-options

Looks like this can be solved with https://poethepoet.natn.io/tasks/task_types/switch.html.

SiPaRadix commented 6 months ago

From the documentation in the link above:

switch tasks support all of the standard task options with the exception of use_exec.

Does that not mean a subprocess is spawned regardless?

Alternatively, could we consider adding exec in front of uvicorn ... and gunicorn ... and avoid spawning a subprocess that way or is it already too late since a subprocess of the poe cli is already spawned at that point? From the PyPI project description:

Normally tasks are executed as subprocesses of the poe cli.

lsorber commented 6 months ago

Yes, Poe will spawn a subprocess. Poe added the ability to exec a command at our request a while back. And we want to exec the process because of the reasons explained in this comment.

Unfortunately, I don't think adding exec will help because that will just replace the process that Poe starts to run the shell script (and not the Poe process itself).

One solution is to replace the current shell switch to a Poe switch task, in which case we can exec the switched commands.