Fix rpc socket.
parent
5debffbd58
commit
d19d8c0198
|
@ -30,7 +30,11 @@ async def run_access_socket(path:str, async_callback, fork:bool):
|
||||||
uid = str(tmp)
|
uid = str(tmp)
|
||||||
|
|
||||||
# Run callback
|
# 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)
|
server = await asyncio.start_unix_server(run_func, path=path)
|
||||||
os.chmod(path, 0o666)
|
os.chmod(path, 0o666)
|
||||||
if fork:
|
if fork:
|
||||||
|
@ -46,7 +50,7 @@ def rpc_callback(async_func):
|
||||||
while not read.at_eof():
|
while not read.at_eof():
|
||||||
# Read data
|
# Read data
|
||||||
try:
|
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:
|
except asyncio.exceptions.IncompleteReadError:
|
||||||
return # Client closed normaly
|
return # Client closed normaly
|
||||||
data = json.loads((await read.readexactly(size)).decode("UTF-8"))
|
data = json.loads((await read.readexactly(size)).decode("UTF-8"))
|
||||||
|
|
Loading…
Reference in New Issue