diff --git a/home_backup/utils.py b/home_backup/utils.py index a5ee982..faeba97 100644 --- a/home_backup/utils.py +++ b/home_backup/utils.py @@ -30,7 +30,11 @@ async def run_access_socket(path:str, async_callback, fork:bool): uid = str(tmp) # Run callback - await async_callback(read, write, uid) + try: + await async_callback(read, write, uid) + finally: + write.close() + await write.wait_closed() server = await asyncio.start_unix_server(run_func, path=path) os.chmod(path, 0o666) if fork: @@ -46,7 +50,7 @@ def rpc_callback(async_func): while not read.at_eof(): # Read data try: - size = _format_length.unpack(await read.readexactly(_format_length.size)) + (size,) = _format_length.unpack(await read.readexactly(_format_length.size)) except asyncio.exceptions.IncompleteReadError: return # Client closed normaly data = json.loads((await read.readexactly(size)).decode("UTF-8"))