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
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)
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
def test_map_future(): f = Future() mf = concurrent.map_future(f, lambda x: x + 1) f.set_result(1) assert mf.result() == 2
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
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)