Skip to content

fix(gee): close the EESession HTTP client on GEEInterface.close() - #1000

Merged
dfguerrerom merged 1 commit into
mainfrom
fix/gee-interface-session-aclose
Jul 6, 2026
Merged

fix(gee): close the EESession HTTP client on GEEInterface.close()#1000
dfguerrerom merged 1 commit into
mainfrom
fix/gee-interface-session-aclose

Conversation

@dfguerrerom

Copy link
Copy Markdown
Collaborator

Problem

GEEInterface.close() stops the event loop and joins its thread, but never awaits session.aclose(). The EESession's httpx.AsyncClient (HTTP/2 pool, sockets, TLS state) is abandoned to the garbage collector, so its release on kernel cull is non-deterministic — connections linger until whenever GC runs, and any accidental surviving reference would turn it into a real leak.

(Found during the se.plan memory investigation. Note this is NOT the RSS-ratchet fix — that one is allocator-level, sepal-contrib/se.plan#275 — this is deterministic-teardown hygiene, measured as not leaking today thanks to GC.)

Fix

Await session.aclose() on the session's own loop (run_coroutine_threadsafe, 5 s timeout) before stopping the loop — ordering matters, aclose needs the loop alive. Failures are logged and never block shutdown; close() stays idempotent.

Tests

Three unit tests in tests/test_scripts/test_gee_interface_close.py, no GEE credentials needed (stub session): aclose runs exactly once on the interface's loop thread; no-session close still clean; an exploding aclose() doesn't block shutdown and double-close is a no-op. Verified red before the fix, green after; rest of the non-GEE suite unchanged (345 passed; the pre-existing network/credential failures are identical on unmodified main).

close() stopped the loop and thread but never awaited session.aclose(),
leaving the httpx AsyncClient (HTTP/2 pool, sockets, TLS state) to the
garbage collector. Run aclose() on the session's own loop, with a 5 s
timeout, before stopping it.
@dfguerrerom
dfguerrerom merged commit 3dc5ade into main Jul 6, 2026
9 checks passed
@dfguerrerom
dfguerrerom deleted the fix/gee-interface-session-aclose branch July 6, 2026 08:18
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

Successfully merging this pull request may close these issues.

1 participant