Skip to content
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

UNIX socket is automatically unlinked #28

Closed
AndreLouisCaron opened this issue May 20, 2016 · 8 comments
Closed

UNIX socket is automatically unlinked #28

AndreLouisCaron opened this issue May 20, 2016 · 8 comments

Comments

@AndreLouisCaron
Copy link

When using the built-in event loop, you need to do something like this:

server = await asyncio.start_unix_server(client_connected, path=path)
try:
    # ...
finally:
    server.close()
    await server.wait_closed()
    os.unlink(path)

However, when I use uvloop, the os.unlink() call raises a FileNotFoundError exception.

I was wondering if you already know about this and if it is intentional?

I don't mind adding a try/except clause to silence the exception, but if you're aiming for this event loop to be a drop-in replacement for the built-in event loop, I guess you're going to want to change this?

@1st1
Copy link
Member

1st1 commented May 20, 2016

Hm, libuv unlinks the path unconditionally, I can't do anything about it.

@saghul, sorry for bothering you, do you think it's possible to add a flag in libuv to tell it not to unlink the path in uv__pipe_close?

@1st1 1st1 changed the title UNIX socket is automatically unliked UNIX socket is automatically unlinked May 20, 2016
@1st1
Copy link
Member

1st1 commented May 20, 2016

Alternatively we can re-create the path once the unix socket is closed, but it feels too hacky to me.

@saghul
Copy link

saghul commented May 20, 2016

No worries Yuri. I don't think we'd do that. See the comment before the unlink, it prevents a race.

Alternatively, you can create a UNIX socket with the Python socket module and use uv_pipe_open, that way the path won't be unlinked because libuv doesn't store it.

@1st1
Copy link
Member

1st1 commented May 20, 2016

@saghul Good idea, I followed your advice :)

@AndreLouisCaron Thanks for reporting this! Should be fixed in the master branch; I'll also issue a new uvloop release shortly.

@AndreLouisCaron
Copy link
Author

Thanks!

@1st1
Copy link
Member

1st1 commented May 21, 2016

I've just released uvloop v0.4.26. Please check it out.

@AndreLouisCaron
Copy link
Author

Just tried 0.4.26 and it now works as expected! Thanks!

@1st1
Copy link
Member

1st1 commented May 22, 2016

Thanks! Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants