Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get/Set Metadata is Hard to Reason About #56

Open
biniona opened this issue Oct 9, 2024 · 0 comments
Open

Get/Set Metadata is Hard to Reason About #56

biniona opened this issue Oct 9, 2024 · 0 comments
Labels

Comments

@biniona
Copy link
Contributor

biniona commented Oct 9, 2024

As noted in a code review (#49 (comment)), it is confusing to reason about how the sync/async _[a]get_by_metadata code paths. __contains__ only uses the synchronous _get_by_metadata as it does not need ever intiailize objects, where as aget/get need to be conscious of which _aget_by_metadata method they use.

A possible refactor could be to convert _get_by_metadata and _aget_by_metadata into the following methods:

  • _get_by_metadata - only gets by metadata if present, never sets by metdata
  • _set_by_metatdata` - only sets metadata for synchronous objects, throws on async objects
  • aysnc _aset_by_metadata - sets metadata for async objects or sync objects using asyncio.to_thread

This would be a clearer split between what code paths need to be split into async and sync (creating new objects) and what code paths can be shared between async / sync code (getting / checking for existence of objects).

@biniona biniona mentioned this issue Oct 9, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant