Skip to content

Make the 51Did client asynchronous with no synchronous form - #78

Merged
Automation51D merged 2 commits into
mainfrom
feature/did-client-async
Sep 10, 2026
Merged

Make the 51Did client asynchronous with no synchronous form#78
Automation51D merged 2 commits into
mainfrom
feature/did-client-async

Conversation

@jwrosewell

Copy link
Copy Markdown
Contributor

What changed

Every method on DidClient that reaches the cloud is now a coroutine, and the synchronous forms are removed outright. This is one of a set of changes making every 51Did client and every OWID port asynchronous where the network is involved, so the libraries behave the same way in every language.

Methods that never touch the network are unchanged, so endpoint, resource_key, has_licence_key, the parsing helpers and the key selection helpers all stay synchronous.

Removed

  • def public_keys(self) -> List[PublicKeyEntry]
  • def public_key_for(self, fod_id) -> Optional[PublicKeyEntry]
  • def verify_signature(self, fod_id) -> bool
  • def verify_signature_detailed(self, fod_id) -> SignatureCheck
  • def verify(self, fod_id) -> bool
  • def redeem(self, fod_id, result, ...) -> RedeemResult

New

The same six with the same names, arguments and return types, as async def. The transport type changes with them.

Transport = Callable[[urllib.request.Request], Awaitable[Tuple[int, bytes]]]

The default transport wraps the existing urllib call on a worker thread through asyncio.to_thread, so it is not fully non-blocking. The module documentation says so and points at aiohttp or httpx for a transport that is. No dependency was added and the supported Python version is unchanged.

Kept exactly

The two step verification, the licence key handling, the redeem outcome types, key selection by the latest start at or before the date, and the 401 handling, all as the tests pin them. The key cache now also holds the in-flight fetch, so concurrent callers waiting on one key list make a single request.

The example server and the package documentation were converted with the client, and there are no callers of the removed methods anywhere else in the repository.

Verification

pytest over the package with the owid submodule on the path: 150 passed, 2 skipped. New tests cover two concurrent key list requests making one HTTP call, and concurrent selections past the newest start sharing one fetch.

This client does not use the OWID library's fetch, only its cryptography, so it does not wait on the OWID asynchronous work in SWAN-community.

Notes

Written with AI assistance and reviewed before merging.

jwrosewell and others added 2 commits September 6, 2026 23:08
Every method that reaches the cloud is now a coroutine and the
synchronous forms are removed. This is one of a set of changes making
every 51Did client and every OWID port asynchronous where the network is
involved, so the libraries behave the same way in every language.

The injectable transport is now an async callable with the same request
in, status and body out shape it had before, so a test stub changes only
by becoming a coroutine. The default wraps the standard library's urllib
on a worker thread through asyncio.to_thread, which the documentation
says plainly, pointing at aiohttp or httpx for a fully non-blocking one.
No dependency was added and the supported Python version is unchanged.

The key cache now holds the in-flight fetch, so concurrent callers
waiting on one key list make a single request.
# Conflicts:
#	fiftyone_pipeline_did/tests/test_did_client.py
@Automation51D
Automation51D merged commit 879d3e9 into main Sep 10, 2026
1 check passed
@Automation51D
Automation51D deleted the feature/did-client-async branch September 10, 2026 13: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.

3 participants