From 2a041ae13566a62dacffcf9cba1248d54ce416d6 Mon Sep 17 00:00:00 2001 From: codingl2k1 <138426806+codingl2k1@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:18:08 +0800 Subject: [PATCH] BUG: Fix getstate compatibility (#84) --- python/xoscar/api.py | 2 +- python/xoscar/tests/test_generator.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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()