MCPcopy Index your code
hub / github.com/cloudpipe/cloudpickle / pickle_echo

Function pickle_echo

tests/testutils.py:107–125  ·  view source on GitHub ↗

Read a pickle from stdin and pickle it back to stdout

(stream_in=None, stream_out=None, protocol=None)

Source from the content-addressed store, hash-verified

105
106
107def pickle_echo(stream_in=None, stream_out=None, protocol=None):
108 """Read a pickle from stdin and pickle it back to stdout"""
109 if stream_in is None:
110 stream_in = sys.stdin
111 if stream_out is None:
112 stream_out = sys.stdout
113
114 # Force the use of bytes streams under Python 3
115 if hasattr(stream_in, "buffer"):
116 stream_in = stream_in.buffer
117 if hasattr(stream_out, "buffer"):
118 stream_out = stream_out.buffer
119
120 input_bytes = _read_all_bytes(stream_in)
121 stream_in.close()
122 obj = loads(input_bytes)
123 repickled_bytes = dumps(obj, protocol=protocol)
124 stream_out.write(repickled_bytes)
125 stream_out.close()
126
127
128def call_func(payload, protocol):

Callers 1

testutils.pyFile · 0.85

Calls 3

dumpsFunction · 0.90
_read_all_bytesFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…