asyncio
This commit is contained in:
3
Game.py
3
Game.py
@@ -15,7 +15,8 @@ class Game:
|
||||
print('Received SIGINT. Stopping Game :-)')
|
||||
self.is_running.release()
|
||||
|
||||
async def run(self):
|
||||
@asyncio.coroutine
|
||||
def run(self):
|
||||
self.is_running.acquire()
|
||||
asyncio.run(self.input_handler.handleInputs())
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ class InputHandler:
|
||||
self.isRunning = True
|
||||
self.targets = targets
|
||||
|
||||
async def handleInputs(self):
|
||||
@asyncio.coroutine
|
||||
def handleInputs(self):
|
||||
self.isRunning = True
|
||||
while self.isRunning:
|
||||
event = await Networking().getInputEvent()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import requests_unixsocket as req
|
||||
import socket
|
||||
import asyncio
|
||||
from utils.Singleton import Singleton
|
||||
|
||||
|
||||
@@ -47,7 +48,8 @@ class Networking(metaclass=Singleton):
|
||||
def writeDisplayScore(self, display, score):
|
||||
self.get("/displays/" + display + "/write_score/" + str(score))
|
||||
|
||||
async def getInputEvent(self):
|
||||
@asyncio.coroutine
|
||||
def getInputEvent(self):
|
||||
header = list()
|
||||
while b'\x02' not in header:
|
||||
byte = self.input_socket.recv(1)
|
||||
|
||||
Reference in New Issue
Block a user