Files
flippr-game/Game.py
Jonas Zeunert 0671c504ae asyncio
2020-02-13 21:58:15 +01:00

25 lines
618 B
Python

import asyncio
import signal
class Game:
def __init__(self, input_handler, events, game_state):
self.input_handler = input_handler
self.events = events
self.game_state = game_state
signal.signal(signal.SIGINT, self.interrupt)
self.is_running = asyncio.Condition()
pass
def interrupt(self):
print('Received SIGINT. Stopping Game :-)')
self.is_running.release()
@asyncio.coroutine
def run(self):
self.is_running.acquire()
asyncio.run(self.input_handler.handleInputs())
await self.is_running.wait()
pass