Conversation
|
Just tried to figure out how to serve a unix socket and ended up here, thanks for this effort ... I guess my only capacity to help this along is basically to bump the PR with this comment 😅 There is a whole bunch of stuff here I had no idea that should be taken care of when dealing with sockets... |
|
Oh yeah, could also take it for a test drive! Saw the following warning when running
Seems to do the job 🌞 from functools import partial
from trio import open_nursery, open_unix_socket, run
from trio_socket import serve_unix # gh:python-trio/trio/pull/1433
SOCK_PATH = "/tmp/temp.sock"
async def client():
stream = await open_unix_socket(SOCK_PATH)
async with stream:
await stream.send_all(b"hello, world")
async def server(stream):
async for data in stream:
print(f"received -> {data}")
async def main():
async with open_nursery() as server_nursery:
await server_nursery.start(partial(serve_unix, server, SOCK_PATH))
async with open_nursery() as client_nursery:
client_nursery.start_soon(client)
server_nursery.cancel_scope.cancel()
run(main) |
|
I am also bumping this PR as I think it would be nice to have also UDS server support - thank you @Tronic + @decentral1se you saved me ton of time figuring this out |
| The socket is initially created with a random token appended to its | ||
| name, and then moved over the requested name while protected by a | ||
| separate lock file. The additional names use suffixes on the | ||
| requested name. |
There was a problem hiding this comment.
Why is it necessary here?
There was a problem hiding this comment.
Not sure, should we try removing this?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1433 +/- ##
====================================================
- Coverage 100.00000% 99.72623% -0.27377%
====================================================
Files 124 126 +2
Lines 18460 18629 +169
Branches 1216 1234 +18
====================================================
+ Hits 18460 18578 +118
- Misses 0 39 +39
- Partials 0 12 +12
|
…sockets" This reverts commit 56fda2d.
Implement high level API for UNIX server sockets, based on #279
This needs some more work but I'd like to invite others for comments at this point.