TypeError: cannot pickle '_thread.RLock' object

I’m trying to use an RLock in an actor. I’m getting

/home/albert/git/reclone/THA-Oracle/oracle/tha_oracle/oracle_face/external_app.py:61: in <module>
    class OracleFace:
/home/albert/miniconda3/envs/tha_py/lib/python3.10/site-packages/ray/serve/api.py:287: in decorator
    frozen_app = cloudpickle.loads(cloudpickle.dumps(app))
/home/albert/miniconda3/envs/tha_py/lib/python3.10/site-packages/ray/cloudpickle/cloudpickle_fast.py:73: in dumps
/home/albert/miniconda3/envs/tha_py/lib/python3.10/site-packages/ray/cloudpickle/cloudpickle_fast.py:620: in dump
    return Pickler.dump(self, obj)
E   TypeError: cannot pickle '_thread.RLock' object

Why does it need to pickle the RLock? It’s something used only by the actor, and never passed around.

Ah, this might actually be because I’m using an RLock in a decorator of a serve end point. I use a LRU cache on a serve endpoint, however that might not actually be doing what I expect. And I could see how the function decorator itself is serialised.