예제 #1
0
    def __init__(self,
                 hostname,
                 port=5000,
                 base_path="/",
                 background=False,
                 thread_mover=None,
                 websocket=True,
                 token=None,
                 token_trusted=None):
        super().__init__()
        self.hostname = hostname
        self.port = port or 80
        self.base_path = base_path if base_path.endswith("/") else (base_path +
                                                                    "/")
        self.token = token
        self.token_trusted = token_trusted
        # jobs maps from uid to tasks
        self.jobs = {}
        self.msg_reply_futures = {}

        self.event_loop_main = asyncio.get_event_loop()
        if self.event_loop_main is None:
            raise RuntimeError(
                'The client cannot work without a running event loop')

        self.executor = Executor(self)
        logger.debug("connect")
        self.connect()
        logger.debug("connected")
        self._check_version()
        self.update()
예제 #2
0
    def _send_and_forget(self, msg, msg_id=None):
        vaex.asyncio.check_patch_tornado()
        if msg_id is None:
            msg_id = str(uuid.uuid4())
        self.msg_reply_futures[msg_id] = asyncio.Future()
        auth = {'token': self.token, 'token-trusted': self.token_trusted}

        msg_encoding = vaex.encoding.Encoding()
        data = vaex.encoding.serialize(
            {
                'msg_id': msg_id,
                'msg': msg,
                'auth': auth
            }, msg_encoding)
        assert self.event_loop_main is asyncio.get_event_loop()

        self.websocket.write_message(data, binary=True)
        return msg_id
예제 #3
0
 def _send(self, msg, msg_id=None, wait_for_reply=True, add_promise=None):
     loop = asyncio.get_event_loop()
     return loop.run_until_complete(self._send_async(msg, msg_id))