Skip EINTR errors on raw sockets

This commit is contained in:
Anton Ryzhov
2013-06-20 15:30:51 +04:00
parent baf9aaf26c
commit 1776e2edcc
2 changed files with 14 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
"""
from socket import _fileobject
import errno
import socket
@@ -29,7 +30,13 @@ class FileSocket(_fileobject):
"""Read data from the socket as if it were a file."""
if self._sock is None:
return None
data = self._sock.recv(size)
while True:
try:
data = self._sock.recv(size)
break
except socket.error as serr:
if serr.errno != errno.EINTR:
raise
if data is not None:
return data