Refactor RestClient to avoid creating circular references #239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #238 for background.
Previously the
RestClient
inherited from anAsyncToSerialHelper
utility class that provided methods for calling / wrapping sync and async functions synchronously. Due to the way I wrote theAsyncToSerialHelper
class, it was possible to add an async function to the event loop that contained a reference to both theAsyncToSerialHelper
instance and whatever coroutine was going to run. As a result if the coroutine had a longer lifetime than theAsyncToSerialHelper
instance, thegc
could never collect theAsyncToSerialHelper
instance. Crucially this meant theAsyncToSerialHelper
instance's finalizer method,__del__
would never run any tear down logic. To avoid this, the functionality ofAsyncToSerialHelper
was refactored into a module of functions.fixes #238
hydrotools._restclient
[3.1.0] - 2023-10-25Removals
RestClient.close
finalizers were removed as they are no longer necessary.Changes
_restclient
'saiohttp
version dependency.AsyncToSerialHelper
was refactored into a module of functions. To avoid creation of circular references.Checklist