asynchronous support?
satyamedh opened this issue · comments
I want to make a project with pyboy, sadly the foundation of the project is async, and non-async code blocks it like hell. will there ever be async support??
We're open for PRs if anyone wants to implement support for it.
You can adapt this example if you want PyBoy to run in a separate thread.
from pyboy import PyBoy
import threading, queue
q = queue.Queue()
def player():
pyboy=PyBoy(...)
while True:
try:
item = q.get(block=False)
pyboy.send_input(item)
except queue.Empty:
pass
if pyboy.tick():
return
def comms():
while True:
item = fetch_item()
q.put(item)
t1 = threading.Thread(target=player)
t2 = threading.Thread(target=comms)
t1.start()
t2.start()
t1.join()
t2.kill()
bruh this is over a year old I just realised xD
running in a thread had been good enough so I will be closing this issue :)