cloudpipe / cloudpipe/cloudpickle
register_pickle_by_value appears to not deliver monkeypatches to receiver
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 1
Description
Should I expect `register_pickle_by_value()` to deliver monkeypatches? I don't know if what I'm observing is a bug or only missing functionality.
I have two python environments, A and B. Each has cloudpickle 3.1.2 installed and also a package that I'm developing at work. Let's call it "tdb". I run a script in environment A that looks like this:
```
import sys
import cloudpickle
import tdb
# monkeypatch an attribute of tdb.
tdb.my_function = lambda *args, **kwargs: ["fake", "values"]
def func():
return tdb.my_function()
assert func() == ["fake", "values"]
cloudpickle.register_pickle_by_value(tdb)
pickle_data = cloudpickle.dumps(func, protocol=4)
sys.stdout.buffer.write(pickle_data)
```
I'm piping the output to a script that runs in environment B
```
import pickle
import sys
pickle_data = sys.stdin.buffer.read()
print(pickle_data)
func = pickle.loads(pickle_data)
print(func())
```
But I see the original `tdb.my_function` being called in environment B, not my monkeypatch.
The odd thing is that I can see `lambda` when I print the pickle stream in environment B. It's there in some sense, but isn't being understood on the receiver side.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.