i'm using the OSC library found here. i'd like to programmatically exit the program via sys.exit() when a specific msg is received.
i use something like the following:
oserve = OSC.OSCServer(('localhost', iportarg))
st = threading.Thread(target = oserve.serve_forever)
oserve.addMsgHandler("/logout", logout_handle)
def logout_handle(addr, tags, stuff, source):
sys.exit()
issuing the message '/logout' yields the following error:
OSCServer: SystemExit on request from localhost:55827:
does anyone have any idea why that is? am in within a sub-process that has been thread-locked? it seems like the OSC lib/module won't allow me to issue a system process while it's still active. any ideas would be great...
thanks, jml
Can I suggest an alternative approach, use a flag
done=False
loop untildone
isTrue
then cleanup by killing the st thread and then exiting.Something like this is a little more preferable imo and you can properly cleanup resources.
What we're doing is making an AsyncResult that both greenlets can communicate with, the main greenlet loops until it's ready to quit listening for that async result, the other greenlet has a hook where it executes
logout_handle
eventually which signals the main greenlet it's time to quit.