Example #1
0
 def _blocking_send(
         self,
         req: ray_client_pb2.DataRequest) -> ray_client_pb2.DataResponse:
     if self._in_shutdown:
         from ray.util import disconnect
         disconnect()
         raise ConnectionError(
             "Request can't be sent because the data channel is "
             "terminated. This is likely because the data channel "
             "disconnected at some point before this request was "
             "prepared. Ray Client has been disconnected.")
     req_id = self._next_id()
     req.req_id = req_id
     self.request_queue.put(req)
     data = None
     with self.cv:
         self.cv.wait_for(
             lambda: req_id in self.ready_data or self._in_shutdown)
         if self._in_shutdown:
             from ray.util import disconnect
             disconnect()
             raise ConnectionError(
                 "Sending request failed because the data channel "
                 "terminated. This is usually due to an error "
                 f"in handling the most recent request: {req}. Ray Client "
                 "has been disconnected.")
         data = self.ready_data[req_id]
         del self.ready_data[req_id]
     return data
Example #2
0
 def _async_send(self,
                 req: ray_client_pb2.DataRequest,
                 callback: Optional[ResponseCallable] = None) -> None:
     req_id = self._next_id()
     req.req_id = req_id
     if callback:
         self.asyncio_waiting_data[req_id] = callback
     self.request_queue.put(req)
Example #3
0
 def _async_send(self,
                 req: ray_client_pb2.DataRequest,
                 callback: Optional[ResponseCallable] = None) -> None:
     with self.lock:
         self._check_shutdown()
         req_id = self._next_id()
         req.req_id = req_id
         self.asyncio_waiting_data[req_id] = callback
         self.outstanding_requests[req_id] = req
         self.request_queue.put(req)
Example #4
0
 def _blocking_send(self, req: ray_client_pb2.DataRequest
                    ) -> ray_client_pb2.DataResponse:
     req_id = self._next_id()
     req.req_id = req_id
     self.request_queue.put(req)
     data = None
     with self.cv:
         self.cv.wait_for(lambda: req_id in self.ready_data)
         data = self.ready_data[req_id]
         del self.ready_data[req_id]
     return data
Example #5
0
 def _blocking_send(
         self,
         req: ray_client_pb2.DataRequest) -> ray_client_pb2.DataResponse:
     req_id = self._next_id()
     req.req_id = req_id
     self.request_queue.put(req)
     data = None
     with self.cv:
         self.cv.wait_for(
             lambda: req_id in self.ready_data or self._in_shutdown)
         if self._in_shutdown:
             raise ConnectionError(
                 f"cannot send request {req}: data channel shutting down")
         data = self.ready_data[req_id]
         del self.ready_data[req_id]
     return data
Example #6
0
 def _async_send(self,
                 req: ray_client_pb2.DataRequest,
                 callback: Optional[ResponseCallable] = None) -> None:
     if self._in_shutdown:
         from ray.util import disconnect
         disconnect()
         raise ConnectionError(
             "Request can't be sent because the data channel is "
             "terminated. This is likely because the data channel "
             "disconnected at some point before this request was "
             "prepared. Ray Client has been disconnected.")
     req_id = self._next_id()
     req.req_id = req_id
     if callback:
         self.asyncio_waiting_data[req_id] = callback
     self.request_queue.put(req)
Example #7
0
 def _blocking_send(self, req: ray_client_pb2.DataRequest
                    ) -> ray_client_pb2.DataResponse:
     req_id = self._next_id()
     req.req_id = req_id
     self.request_queue.put(req)
     data = None
     with self.cv:
         self.cv.wait_for(
             lambda: req_id in self.ready_data or self._in_shutdown)
         if self._in_shutdown:
             raise ConnectionError(
                 "Sending request failed because the data channel "
                 "terminated. This is usually due to an error "
                 f"in handling the most recent request: {req}")
         data = self.ready_data[req_id]
         del self.ready_data[req_id]
     return data
Example #8
0
    def _blocking_send(
        self, req: ray_client_pb2.DataRequest
    ) -> ray_client_pb2.DataResponse:
        with self.lock:
            self._check_shutdown()
            req_id = self._next_id()
            req.req_id = req_id
            self.request_queue.put(req)
            self.outstanding_requests[req_id] = req

            self.cv.wait_for(lambda: req_id in self.ready_data or self._in_shutdown)
            self._check_shutdown()

            data = self.ready_data[req_id]
            del self.ready_data[req_id]
            del self.outstanding_requests[req_id]
            self._acknowledge(req_id)

        return data
Example #9
0
 def _async_send(self, req: ray_client_pb2.DataRequest) -> None:
     req_id = self._next_id()
     req.req_id = req_id
     self.request_queue.put(req)