Skip to content

Instantly share code, notes, and snippets.

@alyoshenka
Created April 3, 2023 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alyoshenka/f53b6e9b1481b9d2d608be092c488f13 to your computer and use it in GitHub Desktop.
Save alyoshenka/f53b6e9b1481b9d2d608be092c488f13 to your computer and use it in GitHub Desktop.
Python Events Example
import time
def main(q):
while True:
if q.not_empty:
event = q.get()
print('event:', event)
if event == 'exit':
return
else:
time.sleep(1)
from threading import Thread
from boardsim import main as sim
from queue import Queue
def main():
events = Queue()
events.put('hello')
events.put('world')
events.put('from')
t = Thread(target=sim, args=(events,))
t.start()
events.put('threaded')
events.put('queue')
events.put('exit')
t.join()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment