This seem to be version/OS unrelated. Sample:
import asyncio
import socket
import uvloop
b = bytes('{"msg": "test"}', 'utf-8')
async def main_async(sock: socket.socket):
_, writer = await asyncio.open_unix_connection(sock=sock)
writer.write(b)
await writer.drain()
if __name__ == '__main__':
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect('data/sockets/echo_server.sock')
sock.sendall(b)
uvloop.install()
asyncio.run(main_async(sock)) # sock gets wrongly closed on asyncio.run() termination
sock.sendall(b) # Exception here OSError: [Errno 9] Bad file descriptor
Last line result in exception "OSError: [Errno 9] Bad file descriptor" because sock gets closed right after asyncio.run() terminates. It is wrong behavior, because sock was created outside of asyncio loop and has to be left untouched. The issue doesn't occur using regular asyncio loop.