MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / test_multiprocess

Method test_multiprocess

tests/cloudpickle_test.py:1129–1151  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1127 f() # smoke test
1128
1129 def test_multiprocess(self):
1130 # running a function pickled by another process (a la dask.distributed)
1131 def scope():
1132 def example():
1133 _ = xml.etree.ElementTree.Comment
1134
1135 return example
1136
1137 global xml
1138 import xml.etree.ElementTree
1139
1140 example = scope()
1141
1142 s = cloudpickle.dumps(example, protocol=self.protocol)
1143
1144 # choose "subprocess" rather than "multiprocessing" because the latter
1145 # library uses fork to preserve the parent environment.
1146 command = (
1147 "import base64; import pickle; pickle.loads(base64.b32decode('"
1148 + base64.b32encode(s).decode("ascii")
1149 + "'))()"
1150 )
1151 assert not subprocess.call([sys.executable, "-c", command])
1152
1153 def test_import(self):
1154 # like test_multiprocess except subpackage modules referenced directly

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected