Skip to content

Commit 58a7fa0

Browse files
author
Shubham
committed
Override SyncClient's destructor to call close(), to avoid resource leakage when user forgets to call close()
1 parent 0d165b6 commit 58a7fa0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

objectbox/sync.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ def __init__(self, store: Store, server_urls: list[str],
371371

372372
self.__store.add_store_close_listener(on_store_close=self.__close_sync_client_func())
373373

374+
def __del__(self):
375+
# Close the SyncClient when this instance is destructed
376+
# for ex. when garbage collected.
377+
self.close()
378+
374379
def __close_sync_client_func(self):
375380
def close_sync_client():
376381
self.close()

0 commit comments

Comments
 (0)