Skip to content

Commit

Permalink
add thread handling on keyboard interrupt
Browse files Browse the repository at this point in the history
Signed-off-by: frederik <frederik.anilmarkus@gmail.com>
  • Loading branch information
frede791 authored and dagar committed Dec 8, 2023
1 parent 264108e commit ebbda72
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions simulation-gazebo
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ DEFAULT_DOWNLOAD_DIR = "https://github.com/PX4/PX4-gazebo-models/archive/refs/he


def run(cmd):
subprocess.run(['bash', '-c', cmd], cwd='.')

process_handle = subprocess.Popen(['bash', '-c', cmd], cwd='.')
return process_handle

def main():
is_windows = platform.system() == 'Windows'
Expand Down Expand Up @@ -107,7 +107,14 @@ def main():
if args.gz_ip:
cmd = f'GZ_IP={args.gz_ip} {cmd}'

run(cmd)
try:
process_handle = run(cmd)

while process_handle.poll() is None:
process_handle.wait()

except KeyboardInterrupt:
exit(0)

if __name__ == "__main__":
main()

0 comments on commit ebbda72

Please sign in to comment.