Skip to content

Commit

Permalink
catched KeyboardInterrupt to cleanly exit
Browse files Browse the repository at this point in the history
  • Loading branch information
MaWalla committed Sep 3, 2022
1 parent bb7882e commit db08772
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
2 changes: 1 addition & 1 deletion fxmodes/PulseViz
Submodule PulseViz updated 1 files
+4 −0 main.py
88 changes: 46 additions & 42 deletions main.py
Expand Up @@ -101,47 +101,51 @@
print('ImmersiveFX Core version %s' % VERSION)
print('---------------------------------------------------')

while True:
# the main thread must stay alive and should do as little as possible from this point on.
# heavy lifting is done by the data thread and sending by device threads

if args.display_frametimes:
command = ''
sleep(1)
else:
command = input()
if command == 'reload':
print('reloading...')
fxmode.stop()

try:
with open('config.json') as file:
config = json.load(file)
except FileNotFoundError:
print('config file not found. you need to place config.json into the main.py directory.')
print('There is a config.json.example to use as starting point.')
exit()

fxmode = selected_fxmode(
core_version=VERSION,
config=config,
launch_arguments=args,
)
print('reload done.')

if command == 'start':
print('starting threads...')
fxmode.start_threads()
print('started threads.')

if command == 'stop':
print('stoppting threads...')
fxmode.stop()
print('stopped threads.')

if command == 'exit':
print('exiting...')
fxmode.kill()
break
try:
while True:
# the main thread must stay alive and should do as little as possible from this point on.
# heavy lifting is done by the data thread and sending by device threads

if args.display_frametimes:
command = ''
sleep(1)
else:
command = input()
if command == 'reload':
print('reloading...')
fxmode.stop()

try:
with open('config.json') as file:
config = json.load(file)
except FileNotFoundError:
print('config file not found. you need to place config.json into the main.py directory.')
print('There is a config.json.example to use as starting point.')
exit()

fxmode = selected_fxmode(
core_version=VERSION,
config=config,
launch_arguments=args,
)
print('reload done.')

if command == 'start':
print('starting threads...')
fxmode.start_threads()
print('started threads.')

if command == 'stop':
print('stoppting threads...')
fxmode.stop()
print('stopped threads.')

if command == 'exit':
print('exiting...')
fxmode.kill()
break

except KeyboardInterrupt:
fxmode.kill()

exit()

0 comments on commit db08772

Please sign in to comment.