alexhsamuel / apsis

General-purpose scheduler.
Other
3 stars 3 forks source link

Feature/async client poll #282

Closed alexhsamuel closed 1 year ago

alexhsamuel commented 1 year ago

Uses async rather than sync HTTP requests for polling agent clients. Uses the HTTPX client library.

Complications:

To deal with all of this, we monkeypatch the async event loop to support on-close functions, kind of like atexit for async. We are careful to use a new HTTP client per event loop, but the same client for the entire life of the loop. When we create a new event loop, we register its close function to be run when the loop closes. This synchronizes the lifetime of the client with the lifetime of the loop.

alexhsamuel commented 1 year ago

Still need to fix tests.

alexhsamuel commented 1 year ago

Not sure how to handle the aiohttp client session shutdown gracefully. https://github.com/aio-libs/aiohttp/issues/7328