开发者

What do python sockets do with EINTR?

开发者 https://www.devze.com 2023-03-02 10:49 出处:网络
So far my networking code works fine, but I\'m a bit worried about something I hid under the carpet: The man pages for accept, close, connect, recv and send mention that errno.EINTR can show up when

So far my networking code works fine, but I'm a bit worried about something I hid under the carpet:

The man pages for accept, close, connect, recv and send mention that errno.EINTR can show up when a system call was interrupted by a signal.

I am quite clueless here.

What does pyt开发者_Go百科hon do with that ? Does it automatically retry the call, does it raise a socket.error with that errno ? What is the appropriate thing I should do if that exception is raised ? Can I generate these signals myself in my unittests ?


Python simply retries the call and hides the signal from the user (helps with cross-platform consistency where -EINTR doesn't exist). You can safely ignore the EINTR issue but if you'd like to test it anyway, it's easy to do. Just set up a blocking operation that will not return (such as a socket.accept with no incoming connection) and send the process a signal.

0

精彩评论

暂无评论...
验证码 换一张
取 消