async def kill_actor(self, req) -> aiohttp.web.Response: try: actor_id = req.query["actorId"] ip_address = req.query["ipAddress"] port = req.query["port"] except KeyError: return rest_response(success=False, message="Bad Request") try: options = (("grpc.enable_http_proxy", 0), ) channel = aiogrpc.insecure_channel(f"{ip_address}:{port}", options=options) stub = core_worker_pb2_grpc.CoreWorkerServiceStub(channel) await stub.KillActor( core_worker_pb2.KillActorRequest( intended_actor_id=ray._private.utils.hex_to_binary( actor_id))) except aiogrpc.AioRpcError: # This always throws an exception because the worker # is killed and the channel is closed on the worker side # before this handler, however it deletes the actor correctly. pass return rest_response(success=True, message=f"Killed actor with id {actor_id}")
def kill_actor(self, actor_id, ip_address, port): channel = grpc.insecure_channel("{}:{}".format(ip_address, int(port))) stub = core_worker_pb2_grpc.CoreWorkerServiceStub(channel) def _callback(reply_future): _ = reply_future.result() reply_future = stub.KillActor.future( core_worker_pb2.KillActorRequest( intended_actor_id=ray.utils.hex_to_binary(actor_id))) reply_future.add_done_callback(_callback) return {}