-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: UNIX server sockets #1433
base: main
Are you sure you want to change the base?
RFC: UNIX server sockets #1433
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, should we try removing this?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1433 +/- ##
==========================================
+ Coverage 92.94% 98.57% +5.63%
==========================================
Files 117 117
Lines 17634 17774 +140
Branches 3172 3174 +2
==========================================
+ Hits 16390 17521 +1131
+ Misses 1154 204 -950
+ Partials 90 49 -41
|
…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.