예제 #1
0
파일: client.py 프로젝트: eoelker/pylabrad
 def future(self, *args, **kw):
     wrap = kw.pop('wrap', True)
     tag = kw.pop('tag', None) or self.accepts_type
     if not len(args):
         args = None
     elif len(args) == 1:
         args = args[0]
     flat = T.flatten(args, tag)
     f = self._server._send([(self.ID, flat)], **kw)
     if wrap:
         f = map_future(f, lambda resp: resp[0][1])
     return f
예제 #2
0
 def future(self, *args, **kw):
     wrap = kw.pop('wrap', True)
     tag = kw.pop('tag', None) or self.accepts
     if not len(args):
         args = None
     elif len(args) == 1:
         args = args[0]
     flat = T.flatten(args, tag)
     f = self._server._send([(self.ID, flat)], **kw)
     if wrap:
         f = map_future(f, lambda resp: resp[0][1])
     return MutableFuture(f)
예제 #3
0
def test_map_future_on_already_completed_future():
    f = Future()
    f.set_result(1)
    mf = concurrent.map_future(f, lambda x: x + 1)
    assert mf.result() == 2
예제 #4
0
def test_map_future():
    f = Future()
    mf = concurrent.map_future(f, lambda x: x + 1)
    f.set_result(1)
    assert mf.result() == 2
예제 #5
0
def test_map_future_on_already_completed_future():
    f = Future()
    f.set_result(1)
    mf = concurrent.map_future(f, lambda x: x + 1)
    assert mf.result() == 2
예제 #6
0
def test_map_future():
    f = Future()
    mf = concurrent.map_future(f, lambda x: x + 1)
    f.set_result(1)
    assert mf.result() == 2
예제 #7
0
파일: client.py 프로젝트: eoelker/pylabrad
 def send_future(self, **kw):
     """Send this packet to the server and get the result as a future."""
     records = [(rec.ID, rec.flat) for rec in self._packet]
     f = self._server._send(records, **dict(self._kw, **kw))
     f = map_future(f, PacketResponse, self._server, self._packet)
     return f
예제 #8
0
 def send_future(self, **kw):
     """Send this packet to the server and get the result as a future."""
     records = [(rec.ID, rec.flat) for rec in self._packet]
     f = self._server._send(records, **dict(self._kw, **kw))
     f = map_future(f, PacketResponse, self._server, self._packet)
     return MutableFuture(f)