diff --git a/python/xoscar/api.py b/python/xoscar/api.py index a1ff18df..59a99d76 100644 --- a/python/xoscar/api.py +++ b/python/xoscar/api.py @@ -325,7 +325,7 @@ def __aiter__(self): def __getstate__(self): # Transfer gc destroy during serialization. - state = dict(**super().__getstate__()) + state = self.__dict__.copy() state["_gc_destroy"] = True self._gc_destroy = False return state diff --git a/python/xoscar/tests/test_generator.py b/python/xoscar/tests/test_generator.py index 806d7c2e..3ebb15ad 100644 --- a/python/xoscar/tests/test_generator.py +++ b/python/xoscar/tests/test_generator.py @@ -13,6 +13,7 @@ # limitations under the License. import asyncio +import pickle import time import pytest @@ -161,6 +162,7 @@ async def test_generator(): assert len(all_gen) == 0 r = await superivsor_actor.with_exception() + pickle.loads(pickle.dumps(r)) del r await asyncio.sleep(0) all_gen = await superivsor_actor.get_all_generators()