THRIFT-5454: add __setState__ function to TProcessPoolServer to enable correct multiprocessing behavior related to pickling

Client: Python
This commit is contained in:
Yiyang Zhou 2021-08-13 16:30:58 +08:00 committed by Jens Geyer
parent ea39a14a1f
commit da1e19b72b

View File

@ -42,6 +42,11 @@ class TProcessPoolServer(TServer):
self.stopCondition = Condition() self.stopCondition = Condition()
self.postForkCallback = None self.postForkCallback = None
def __getstate__(self):
state=self.__dict__.copy()
state['workers'] = None
return state
def setPostForkCallback(self, callback): def setPostForkCallback(self, callback):
if not callable(callback): if not callable(callback):
raise TypeError("This is not a callback!") raise TypeError("This is not a callback!")