Renamed message_handler to event_handler

This commit is contained in:
Nocturn9x 2023-05-10 12:20:45 +02:00
parent 089d525def
commit 7272516e78
Signed by: nocturn9x
GPG Key ID: 8270F9F467971E59
1 changed files with 4 additions and 4 deletions

View File

@ -8,16 +8,16 @@ clients: dict[aiosched.socket.AsyncSocket, list[str, str]] = {}
names: set[str] = set() names: set[str] = set()
async def message_handler(q: aiosched.Queue): async def event_handler(q: aiosched.Queue):
""" """
Reads data submitted onto the queue Reads data submitted onto the queue
""" """
try: try:
logging.info("Message handler spawned") logging.info("Event handler spawned")
while True: while True:
msg, payload = await q.get() msg, payload = await q.get()
logging.info(f"Got message {msg!r} with the following payload: {payload}") logging.info(f"Caught event {msg!r} with the following payload: {payload}")
except Exception as e: except Exception as e:
logging.error(f"An exception occurred in the message handler -> {type(e).__name__}: {e}") logging.error(f"An exception occurred in the message handler -> {type(e).__name__}: {e}")
except aiosched.errors.Cancelled: except aiosched.errors.Cancelled:
@ -40,7 +40,7 @@ async def serve(bind_address: tuple):
await sock.listen(5) await sock.listen(5)
logging.info(f"Serving asynchronously at {bind_address[0]}:{bind_address[1]}") logging.info(f"Serving asynchronously at {bind_address[0]}:{bind_address[1]}")
async with aiosched.create_pool() as pool: async with aiosched.create_pool() as pool:
await pool.spawn(message_handler, queue) await pool.spawn(event_handler, queue)
async with sock: async with sock:
while True: while True:
try: try: