Beispiel #1
0
    def __setitem__(self, key, value):
        assert key == id(value)

        if key not in self._small:
            path = self._pickle_path(key)

            if not os.path.exists(path):
                pickled = pickle.dumps(value)

                if len(pickled) > self._threshold:
                    with open(path, "wb") as pickle_file:
                        pickle_file.write(condor.compress(pickled))
                else:
                    self._small[key] = pickled

        return value
Beispiel #2
0
def send_pyobj_compressed(zmq_socket, message):
    pickled = pickle.dumps(message, protocol = -1)
    compressed = condor.compress(pickled)

    zmq_socket.send(compressed)