Skip to content

Commit

Permalink
Added custom serializer for to enable picking of thread.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavgarg1 committed Sep 15, 2022
1 parent 5b459fa commit 80412e7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ludwig/hyperopt/syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class RemoteSyncer(_BackgroundSyncer):
def __init__(self, backend: Backend, sync_period: float = 300.0):
def __init__(self, sync_period: float = 300.0, backend: Backend = None):
super().__init__(sync_period=sync_period)
self.backend = backend

Expand All @@ -32,3 +32,9 @@ def _delete_command(self, uri: str) -> Tuple[Callable, Dict]:
delete_at_uri,
dict(uri=uri),
)

# Custom deserialization needed since we can't pickle thread.lock objects
def __reduce__(self):
deserializer = RemoteSyncer
serialized_data = (self.sync_period, self.backend)
return deserializer, serialized_data

0 comments on commit 80412e7

Please sign in to comment.