Skip to content

Instantly share code, notes, and snippets.

@valsteen
Last active September 20, 2015 16:23
Show Gist options
  • Save valsteen/29a22d6e7cd57360b174 to your computer and use it in GitHub Desktop.
Save valsteen/29a22d6e7cd57360b174 to your computer and use it in GitHub Desktop.
how to keep python interpreter busy in ableton
def pause(self):
# helper for rconsole. This blocks ableton inside python on purpose, otherwise the console thread
# is super slow ( python interpreter is only active when needed )
def lock():
if self.console_event.isSet():
return
# this trick works with Event and not with just time.sleep, because in python2 Event.wait is a loop+sleep, which keeps the interpreter busy
self.console_event.wait(0.1)
self.schedule_message(3, lock)
self.console_event.clear() # console_event is a threading.Event object
self.schedule_message(3, lock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment