From 57dcb401decae30d53b57a01440e08a36127caa4 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Thu, 25 Dec 2025 01:00:19 -0500 Subject: [PATCH] hopefully the final unfuck to employee's networking --- employee.py | 26 +++++++++++++++----------- queuers/reenc.py | 6 +++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/employee.py b/employee.py index 05f03f53c601f5e83ef44685f71393e27efefd4c..832d61d1e7307c45858bd26d4f2e144cb8c5c260 100755 --- a/employee.py +++ b/employee.py @@ -42,7 +42,6 @@ co_lock = asyncio.Lock() class JobError(Exception): pass async def send_cmd(reader, writer, cmd): - global co_lock async def impl(): @@ -50,13 +49,11 @@ async def send_cmd(reader, writer, cmd): async with co_lock: writer.write(cmd.encode()+b'\n') - print(cmd) await writer.drain() while True: line = (await reader.readline()).rstrip() - print(line) if line == b'?': - raise JobError(cmd) + raise JobError(f'{cmd} {lines}') elif line == b'OKAY': return lines else: @@ -66,6 +63,8 @@ async def send_cmd(reader, writer, cmd): async def take_job(reader, writer): + global co_lock + l = logging.getLogger('employee.job') while True: @@ -82,14 +81,17 @@ async def take_job(reader, writer): l.info(f'took job {jid}') - writer.write(b'SCRIPT IS\n') - await writer.drain() + async with co_lock: + writer.write(b'SCRIPT IS\n') + await writer.drain() - line = (await reader.readline()).strip() - length = int(line.decode()) - script = await reader.readexactly(length) - - await reader.readline() + line = (await reader.readline()).strip() + if line == b'?': + raise JobError('SCRIPT IS') + length = int(line.decode()) + script = await reader.readexactly(length) + + await reader.readline() return script @@ -181,6 +183,8 @@ async def main(): l.info(f'connected!') while True: + try: + script = await take_job(reader, writer) await run_script(reader, writer, script) diff --git a/queuers/reenc.py b/queuers/reenc.py index 052063373285c9bd5a5687ab6266c0f9b783c1a1..c7bd8889868d1a5a73a4b0d054b37c824d296ccf 100644 --- a/queuers/reenc.py +++ b/queuers/reenc.py @@ -26,8 +26,8 @@ from typing import Optional from os import system import socket -RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)] -#RESOLUTIONS=[(710, 480), (1136, 768)] +#RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)] +RESOLUTIONS=[(710, 480), (1136, 768)] argv0 = 'reenc.py' @@ -41,7 +41,7 @@ class JobError(Exception): def send_cmd(reader, writer, cmd): lines = [] - writer.write(cmd.encode()+b'\n') + writer.write(cmd+'\n') writer.flush() while True: line = reader.readline()