Skip to content

Commit 35491bd

Browse files
committed
Merge pull request pandas-dev#24 from manahl/getstate_pass_all_init_params
Ensure Arctic.__getstate__ persists all init params.
2 parents 9a0fc60 + af337f0 commit 35491bd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arctic/arctic.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ def __repr__(self):
130130
return str(self)
131131

132132
def __getstate__(self):
133-
return {'mongo_host': self.mongo_host, 'allow_secondary': self._allow_secondary}
133+
return {'mongo_host': self.mongo_host,
134+
'app_name': self._application_name,
135+
'allow_secondary': self._allow_secondary,
136+
'socketTimeoutMS': self._socket_timeout,
137+
'connectTimeoutMS': self._connect_timeout,
138+
'serverSelectionTimeoutMS': self._server_selection_timeout}
134139

135140
def __setstate__(self, state):
136141
return Arctic.__init__(self, **state)

tests/unit/test_arctic.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,13 @@ def test_mongo_host_get_set():
326326

327327
def test_arctic_set_get_state():
328328
sentinel.mongo_host = Mock(nodes={("host", "port")})
329-
store = Arctic(sentinel.mongo_host, allow_secondary="allow_secondary")
329+
store = Arctic(sentinel.mongo_host, allow_secondary="allow_secondary", app_name="app_name",
330+
socketTimeoutMS=1234, connectTimeoutMS=2345, serverSelectionTimeoutMS=3456)
330331
buff = pickle.dumps(store)
331332
mnew = pickle.loads(buff)
332333
assert mnew.mongo_host == "host:port"
333334
assert mnew._allow_secondary == "allow_secondary"
335+
assert mnew._application_name == "app_name"
336+
assert mnew._socket_timeout == 1234
337+
assert mnew._connect_timeout == 2345
338+
assert mnew._server_selection_timeout == 3456

0 commit comments

Comments
 (0)