Conversation
When Store is closed, the Sync client should be closed too
Include Sync libraries when building Sync package
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37bee34205
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| c.obx_sync_listener_error(self.__c_sync_client_ptr, None, None) | ||
| c.obx_sync_listener_login(self.__c_sync_client_ptr, None, None) | ||
| c.obx_sync_listener_login_failure(self.__c_sync_client_ptr, None, None) | ||
| c.obx_sync_listener_connect(self.__c_sync_client_ptr, None, None) | ||
| c.obx_sync_listener_disconnect(self.__c_sync_client_ptr, None, None) |
There was a problem hiding this comment.
Make SyncClient.close idempotent before C calls
In close(), the C cleanup functions are called unconditionally with self.__c_sync_client_ptr. Because a store-close listener is registered and users can also call SyncClient.close() manually, it’s easy to hit a second close (e.g., client.close() then store.close()), which will pass a NULL handle into the C API. That contradicts the docstring (“Does nothing if this sync client has already been closed”) and can lead to C-level errors or crashes if the native API does not accept NULL. Add a guard (if self.__c_sync_client_ptr is None: return) before invoking the C functions to make close truly idempotent.
Useful? React with 👍 / 👎.
| if store in Sync.__sync_clients: | ||
| raise ValueError('Only one sync client can be active for a store') | ||
| client = SyncClient(store, server_urls, filter_variables) | ||
| client.set_multiple_credentials(credentials_list) | ||
| Sync.__sync_clients[store] = client |
There was a problem hiding this comment.
Remove closed clients from Sync.__sync_clients
client_multi_creds_multi_urls() stores the new client in Sync.__sync_clients and rejects future creations for the same store, but nothing ever removes that entry on SyncClient.close() or store close. As a result, once a client is closed, calling this factory again with the same store will always raise ValueError even though no client is active. This prevents restarting sync for a store without restarting the process; consider removing the store from the registry when the client closes.
Useful? React with 👍 / 👎.
No description provided.