예제 #1
0
 def test_mmap(self, tmpdir, val):
     mmap = pytest.importorskip("mmap").mmap
     p = tmpdir.join("data")
     with p.open("wb") as f:
         f.write(execnet.dumps(val))
     f = p.open("r+b")
     m = mmap(f.fileno(), 0)
     val2 = execnet.load(m)
     assert val == val2
예제 #2
0
 def test_mmap(self, tmpdir, val):
     mmap = pytest.importorskip("mmap").mmap
     p = tmpdir.join("data")
     with p.open("wb") as f:
         f.write(execnet.dumps(val))
     f = p.open("r+b")
     m = mmap(f.fileno(), 0)
     val2 = execnet.load(m)
     assert val == val2
예제 #3
0
파일: keyfs.py 프로젝트: zerotired/devpi
 def set(self, val):
     if not isinstance(val, self.type):
         raise TypeError("%r requires value of type %r, got %r" %(
                         self.relpath, self.type.__name__,
                         type(val).__name__))
     if self.type == bytes:
         data = val
     else:
         data = dumps(val)
     self.keyfs._set(self.relpath, data)
예제 #4
0
 def set(self, val):
     if not isinstance(val, self.type):
         raise TypeError("%r requires value of type %r, got %r" %(
                         self.relpath, self.type.__name__,
                         type(val).__name__))
     if self.type == bytes:
         data = val
     else:
         data = dumps(val)
     self.keyfs._set(self.relpath, data)
예제 #5
0
    def set(self, key, value):
        """ save value for the given key.

        :param key: must be a ``/`` separated value. Usually the first
             name is the name of your plugin or your application.
        :param value: must be of any combination of basic
               python types, including nested types
               like e. g. lists of dictionaries.
        """
        from execnet import dumps, DataFormatError
        path = self._getvaluepath(key)
        f = path.open("wb")
        try:
            try:
                self.trace("cache-write %s: %r" % (key, value,))
                return f.write(dumps(value))
            finally:
                f.close()
        except DataFormatError:
            raise ValueError("cannot serialize a builtin python type")
예제 #6
0
    def set(self, key, value):
        """ save value for the given key.

        :param key: must be a ``/`` separated value. Usually the first
             name is the name of your plugin or your application.
        :param value: must be of any combination of basic
               python types, including nested types
               like e. g. lists of dictionaries.
        """
        from execnet import dumps, DataFormatError
        path = self._getvaluepath(key)
        f = path.open("wb")
        try:
            try:
                self.trace("cache-write %s: %r" % (key, value,))
                return f.write(dumps(value))
            finally:
                f.close()
        except DataFormatError:
            raise ValueError("cannot serialize a builtin python type")
예제 #7
0
def test_serializer_api_version_error(monkeypatch):
    bchr = gateway_base.bchr
    monkeypatch.setattr(gateway_base, 'DUMPFORMAT_VERSION', bchr(1))
    dumped = execnet.dumps(42)
    monkeypatch.setattr(gateway_base, 'DUMPFORMAT_VERSION', bchr(2))
    pytest.raises(execnet.DataFormatError, lambda: execnet.loads(dumped))
예제 #8
0
 def test_serializer_api(self, val):
     dumped = execnet.dumps(val)
     val2 = execnet.loads(dumped)
     assert val == val2
예제 #9
0
def test_serializer_api_version_error(monkeypatch):
    bchr = gateway_base.bchr
    monkeypatch.setattr(gateway_base, 'DUMPFORMAT_VERSION', bchr(1))
    dumped = execnet.dumps(42)
    monkeypatch.setattr(gateway_base, 'DUMPFORMAT_VERSION', bchr(2))
    pytest.raises(execnet.DataFormatError, lambda: execnet.loads(dumped))
예제 #10
0
 def test_serializer_api(self, val):
     dumped = execnet.dumps(val)
     val2 = execnet.loads(dumped)
     assert val == val2
 def process_individual_data(self):
     """
     traite et renvoie les données nécessaires à la création de l'individu
     :return: la serialisation des données traitées
     """
     return execnet.dumps(None)
 def data(dataitem):
     return execnet.dumps(("value", dataitem))
 def command(cmd):
     return execnet.dumps(("cmd", cmd))