diff --git a/google/auth/_refresh_worker.py b/google/auth/_refresh_worker.py index 9bb0ccc2c..674032d84 100644 --- a/google/auth/_refresh_worker.py +++ b/google/auth/_refresh_worker.py @@ -75,7 +75,7 @@ def __getstate__(self): def __setstate__(self, state): """Pickle helper that deserializes the _lock attribute.""" - state["_key"] = threading.Lock() + state["_lock"] = threading.Lock() self.__dict__.update(state) diff --git a/system_tests/secrets.tar.enc b/system_tests/secrets.tar.enc index 506ef1415..79c9bb6b6 100644 Binary files a/system_tests/secrets.tar.enc and b/system_tests/secrets.tar.enc differ diff --git a/tests/test__refresh_worker.py b/tests/test__refresh_worker.py index f842b02ca..c25965d10 100644 --- a/tests/test__refresh_worker.py +++ b/tests/test__refresh_worker.py @@ -150,7 +150,10 @@ def test_refresh_dead_worker(): def test_pickle(): w = _refresh_worker.RefreshThreadManager() + # For some reason isinstance cannot interpret threading.Lock as a type. + assert w._lock is not None pickled_manager = pickle.dumps(w) manager = pickle.loads(pickled_manager) assert isinstance(manager, _refresh_worker.RefreshThreadManager) + assert manager._lock is not None