Skip to content

Commit e211164

Browse files
committed
handle nonewline case
1 parent 3795b40 commit e211164

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/rovr/functions/ipc_instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def publish_instance(port: int, token: str) -> Path:
4646
os.replace(temporary, destination)
4747
# safety first
4848
destination.chmod(0o600)
49-
except Exception:
49+
except BaseException:
5050
temporary.unlink(missing_ok=True)
5151
raise
5252
return destination

src/rovr/functions/ipc_receiver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ async def conn(
6767
writer: asyncio.StreamWriter,
6868
token: str,
6969
) -> None:
70-
data = await reader.readline()
70+
try:
71+
data = await asyncio.wait_for(reader.readline(), timeout=1)
72+
except asyncio.TimeoutError:
73+
assemble_and_write(writer, False, err="no newline")
74+
return
7175
parsed: IPCReceiver = json.loads(data.decode())
7276
if parsed.get("token") != token:
7377
assemble_and_write(writer, False, err="unauthorized")
@@ -453,7 +457,7 @@ async def wrapper(
453457
await writer.wait_closed()
454458

455459

456-
@work
460+
@work(group="ipc")
457461
async def start_server(self: Application) -> None:
458462
from rovr.functions.ipc_instances import publish_instance, unpublish_instance
459463

0 commit comments

Comments
 (0)