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

add_signal_handler should raise NotImplementedError on Windows #85

Open
pquentin opened this issue Jun 10, 2020 · 3 comments
Open

add_signal_handler should raise NotImplementedError on Windows #85

pquentin opened this issue Jun 10, 2020 · 3 comments

Comments

@pquentin
Copy link
Member

uvicorn relies on this behavior: https://github.com/encode/uvicorn/blob/77468df/uvicorn/main.py#L568-L577. Running the code in #84 results in the following traceback on Windows:

{PATH}trio_asyncio\_base.py:20: TrioDeprecationWarning: trio.hazmat is deprecated since Trio 0.15.0; use trio.lowlevel instead (https://github.com/python-trio/trio/issues/476)
  from trio.hazmat import wait_for_child
{PATH}trio_asyncio\_loop.py:267: TrioAsyncioDeprecationWarning: Using trio-asyncio outside of a Trio event loop is deprecated since trio-asyncio 0.10.0 with no replacement
  return _trio_policy.new_event_loop()
Traceback (most recent call last):
  File ".\server.py", line 20, in <module>
    trio_asyncio.run(trio_asyncio.aio_as_trio(server.serve))
  File "{PATH}trio_asyncio\_loop.py", line 429, in run
    return trio.run(_run_task, proc, args)
  File "{PATH}trio\_core\_run.py", line 1795, in run
    raise runner.main_task_outcome.error
  File "{PATH}trio_asyncio\_loop.py", line 427, in _run_task
    return await proc(*args)
  File "{PATH}trio_asyncio\_adapter.py", line 56, in __call__
    return await self.loop.run_aio_coroutine(f)
  File "{PATH}trio_asyncio\_base.py", line 240, in run_aio_coroutine
    return await run_aio_future(fut)
  File "{PATH}trio_asyncio\_util.py", line 45, in run_aio_future
    res = await trio.hazmat.wait_task_rescheduled(abort_cb)
  File "{PATH}trio\_core\_traps.py", line 165, in wait_task_rescheduled
    return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()
  File "{PATH}outcome\_sync.py", line 111, in unwrap
    raise captured_error
  File "{PATH}trio_asyncio\_adapter.py", line 19, in _call_defer
    return await proc(*args, **kwargs)
  File "{PATH}uvicorn\main.py", line 393, in serve
    self.install_signal_handlers()
  File "{PATH}uvicorn\main.py", line 565, in install_signal_handlers
    loop.add_signal_handler(sig, self.handle_exit, sig, None)
  File "{PATH}trio_asyncio\_base.py", line 488, in add_signal_handler
    self._check_signal(sig)
AttributeError: 'TrioEventLoop' object has no attribute '_check_signal'
@pquentin
Copy link
Member Author

Fixing this would allow to run FastAPI with uvicorn on Windows: https://gitter.im/python-trio/general?at=5ee0cc5d49260560aa512a42

@njsmith
Copy link
Member

njsmith commented Jun 10, 2020 via email

@pquentin
Copy link
Member Author

Yes, I think that would work too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants