Skip to content

Commit

Permalink
Stopping RQD killframe exception when frame is not running (#171)
Browse files Browse the repository at this point in the history
* Fixes Issue #168 . Dont have rqd throw an exception when the frame is not running
  • Loading branch information
Greg Denton authored Jan 24, 2019
1 parent 083799c commit a3087de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ def launchFrame(self, runFrame):
def getRunningFrame(self, frameId):
try:
return self.__cache[frameId]
except:
raise KeyError("frameId {} is not running on this"
"machine".format(frameId))
except KeyError:
log.info("frameId {} is not running on this machine".format(frameId))
return None

def reportStatus(self, current=None):
"""Replies with hostReport"""
Expand Down
16 changes: 13 additions & 3 deletions rqd/rqd/rqdservicers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import logging as log

import grpc

from compiled_proto import rqd_pb2
from compiled_proto import rqd_pb2_grpc

Expand All @@ -26,14 +28,22 @@ def GetRunningFrameStatus(self, request, context):
"""RPC call to return the frame info for the given frame id"""
log.info("Request received: getRunningFrameStatus")
frame = self.rqCore.getRunningFrame(request.frameId)
return rqd_pb2.RqdStaticGetRunningFrameStatusResponse(
running_frame_info=frame.runningFrameInfo())
if frame:
return rqd_pb2.RqdStaticGetRunningFrameStatusResponse(
running_frame_info=frame.runningFrameInfo())
else:
context.set_details(
"The requested frame was not found. frameId: {}".format(request.frameId))
context.set_code(grpc.StatusCode.NOT_FOUND)
return rqd_pb2.RqdStaticGetRunningFrameStatusResponse()


def KillRunningFrame(self, request, context):
"""RPC call that kills the running frame with the given id"""
log.info("Request received: killRunningFrame")
frame = self.rqCore.getRunningFrame(request.frame_id)
frame.kill()
if frame:
frame.kill()
return rqd_pb2.RqdStaticKillRunningFrameResponse()

def ShutdownRqdNow(self, request, context):
Expand Down

0 comments on commit a3087de

Please sign in to comment.