NOAA-OWP / hydrotools

Suite of tools for retrieving USGS NWIS observations and evaluating National Water Model (NWM) data.
Other
53 stars 12 forks source link

Refactor RestClient to avoid creating circular references #239

Closed aaraney closed 8 months ago

aaraney commented 8 months ago

See #238 for background.

Previously the RestClient inherited from an AsyncToSerialHelper utility class that provided methods for calling / wrapping sync and async functions synchronously. Due to the way I wrote the AsyncToSerialHelper class, it was possible to add an async function to the event loop that contained a reference to both the AsyncToSerialHelper instance and whatever coroutine was going to run. As a result if the coroutine had a longer lifetime than the AsyncToSerialHelper instance, the gc could never collect the AsyncToSerialHelper instance. Crucially this meant the AsyncToSerialHelper instance's finalizer method, __del__ would never run any tear down logic. To avoid this, the functionality of AsyncToSerialHelper was refactored into a module of functions.

fixes #238

hydrotools._restclient [3.1.0] - 2023-10-25

Removals

Changes

Checklist

aaraney commented 8 months ago

Pinging @jarq6c just so you are aware of this. Im going to go ahead and merge.