示例#1
0
 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
 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)