15 Commits

Author SHA1 Message Date
Eric Callahan
0a8590643f
server: refactor startup
Use asyncio.run() to launch the server application as recommended
by the Python docs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-08-08 16:29:01 -04:00
Eric Callahan
9d0d09de80 eventloop: add low level eventloop property
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-18 08:03:47 -04:00
Eric Callahan
bf9223225c
eventloop: fix timer reentrancy
Avoid running multiple callbacks if a timer is stopped and restarted
in quick succession.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:02 -05:00
Eric Callahan
27a0295218
eventloop: remove deprecated uvloop method
Starting in Python 3.12 uvloop.install() is deprecated.  Directly
set the event_loop_policy as advised by the documentation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-07 19:51:48 -05:00
Eric Callahan
51f4d4b888
eventloop: add support for uvloop
Signed-off-by:  Eric Callahan <arskine.code@gmail.com>
2023-10-06 18:20:28 -04:00
Eric Callahan
d6b1a724a8
eventloop: improve callback handling
Wrap all callbacks in a coroutine that handles exceptions.  This
should eliminate "task not retreived" errors.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-12-24 08:07:45 -05:00
Eric Callahan
53a3c64186
moonraker: move loop creation to the eventloop module
Python 3.10 deprecates "get_event_loop()", so it is necessary to
create a new loop and set it as active at startup.  Previously
Moonraker only did this after a soft restart.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-16 19:41:09 -04:00
Eric Callahan
0b31d7d0b2
eventloop: add async create socket method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-28 18:25:16 -04:00
Eric Callahan
1be639b99a eventloop: use the default executor for run_in_thread()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan
47f0437973 eventloop: add a reset method
Rather than instantiate a new version of the event loop wrapper
we can simply reset the internal event loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 18:14:46 -05:00
Eric Callahan
c6cddf4b05 moonraker: logging improvements
Move logging setup to the Server class and enable asyncio debugging.
Sanitize debug logging for all "/access" endpoints so tokens and
passwords are not logged.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-11 14:16:15 -05:00
Eric Callahan
69a06dd12a eventloop: add a timer class
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-09 14:38:32 -05:00
Eric Callahan
484c4aea59 eventloop: fix FlexCallback annotation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan
c2bf9bf551 event_loop: add create_future method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan
07cb64a191 eventloop: initial implementation
This adds a thin wrapper around asyncio's eventloop.  Generally it is similar to Tornado's IOLoop, however without the need to support all awaitables.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00