Skip to content

Commit ca324cb

Browse files
authored
Merge pull request #209 from JdeRobot/issue-207
[WIP] Fixed crash when running error
2 parents cd8da33 + f7888a8 commit ca324cb

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

manager/manager/manager.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,14 +789,28 @@ def process_message(self, message):
789789
self.consumer.send_message(message.response(response))
790790

791791
def on_pause(self, msg):
792-
proc = psutil.Process(self.application_process.pid)
793-
proc.suspend()
794-
self.pause_sim()
792+
if self.application_process is not None:
793+
try:
794+
proc = psutil.Process(self.application_process.pid)
795+
proc.suspend()
796+
self.pause_sim()
797+
except Exception as e:
798+
LogManager.logger.exception("Error suspending process")
799+
else:
800+
LogManager.logger.warning("Application process was None during pause. Calling termination.")
801+
self.on_terminate_application(msg)
795802

796803
def on_resume(self, msg):
797-
proc = psutil.Process(self.application_process.pid)
798-
proc.resume()
799-
self.unpause_sim()
804+
if self.application_process is not None:
805+
try:
806+
proc = psutil.Process(self.application_process.pid)
807+
proc.resume()
808+
self.unpause_sim()
809+
except Exception as e:
810+
LogManager.logger.exception("Error suspending process")
811+
else:
812+
LogManager.logger.warning("Application process was None during resume. Calling termination.")
813+
self.on_terminate_application(msg)
800814

801815
def pause_sim(self):
802816
if self.visualization_type in ["gzsim_rae", "bt_studio_gz"]:

0 commit comments

Comments
 (0)