def test_inspect_serialization(enable_pickle_debug): import threading from ray.cloudpickle import dumps_debug lock = threading.Lock() with pytest.raises(TypeError): dumps_debug(lock) def test_func(): print(lock) with pytest.raises(TypeError): dumps_debug(test_func) class test_class: def test(self): self.lock = lock from ray.util.check_serialize import inspect_serializability results = inspect_serializability(lock) assert list(results[1])[0].obj == lock, results results = inspect_serializability(test_func) assert list(results[1])[0].obj == lock, results results = inspect_serializability(test_class) assert list(results[1])[0].obj == lock, results
def register(self, category, key, value): """Registers the value with the global registry. Raises: PicklingError if unable to pickle to provided file. """ if category not in KNOWN_CATEGORIES: from ray.tune import TuneError raise TuneError("Unknown category {} not among {}".format( category, KNOWN_CATEGORIES)) self._to_flush[(category, key)] = pickle.dumps_debug(value) if _internal_kv_initialized(): self.flush_values()