Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch dev server with use_exec #104

Open
souliane opened this issue Jan 10, 2024 · 0 comments
Open

Launch dev server with use_exec #104

souliane opened this issue Jan 10, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@souliane
Copy link

Is your feature request related to a problem? Please describe.

I can't use my debugger (pudb) with poe api --dev because it is launched in the background. It triggers an error when the debugger is supposed to open:

  File "[...]/site-packages/pudb/debugger.py", line 2683, in event_loop
    keys = self.screen.get_input()
  File "[...]/site-packages/urwid/display/_raw_display_base.py", line 286, in get_input
    keys, raw = self.parse_input(None, None, self.get_available_raw_input())

  [...]

  File "[...]/site-packages/urwid/display/_posix_raw_display.py", line 298, in _getch
    return ord(os.read(fd, 1))
TypeError: ord() expected a character, but string of length 0 found

Describe the solution you would like

Launch the dev server with use_exec = true c.f. https://poethepoet.natn.io/tasks/options.html#defining-tasks-that-run-via-exec-instead-of-a-subprocess

For my project I changed the tasks declarations like that:

  [tool.poe.tasks.dev]
  help = "Serve a REST API for DEV purpose"
  use_exec = true
  cmd = """
    uvicorn \ 
      --host $host \
      --port $port \
      --reload \
      --log-level debug \
      network_manager.api:app
    """

    [[tool.poe.tasks.dev.args]]
    help = "Bind socket to this host (default: 0.0.0.0)"
    name = "host"
    options = ["--host"]
    default = "0.0.0.0"

    [[tool.poe.tasks.dev.args]]
    help = "Bind socket to this port (default: 8000)"
    name = "port"
    options = ["--port"]
    default = "8000"

  [tool.poe.tasks.api]
  help = "Serve a REST API"
  use_exec = true
  cmd = """
    gunicorn \
      --access-logfile - \
      --bind $host:$port \
      --graceful-timeout 10 \
      --keep-alive 10 \
      --log-file - \
      --timeout 30 \
      --worker-class uvicorn.workers.UvicornWorker \
      --worker-tmp-dir /dev/shm \
      --workers 2 \
      network_manager.api:app
    """

    [[tool.poe.tasks.api.args]]
    help = "Bind socket to this host (default: 0.0.0.0)"
    name = "host"
    options = ["--host"]
    default = "0.0.0.0"

    [[tool.poe.tasks.api.args]]
    help = "Bind socket to this port (default: 8000)"
    name = "port"
    options = ["--port"]
    default = "8000"
  • remove the dev option and split the existing task in 2
  • use cmd with use_exec instead of shell

Because when using use_exec, it's not possible to use shell. And when using cmd, it's not possible to use the shell if instruction... there might be a better way but this seems to work.

Additional context

There might be a better solution... but I can create a pull request if you are happy with this.

@souliane souliane added the enhancement New feature or request label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants