-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3928f5b
commit a1d0e47
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sys | ||
import errno | ||
import socket | ||
from rpyc.lib.compat import get_exc_errno | ||
from rpyc.core.stream import SocketStream | ||
from rpyc.utils.server import Server | ||
|
||
|
||
def fix_connect(cls, host, port, **kwargs): | ||
if kwargs.pop("ipv6", False): | ||
kwargs["family"] = socket.AF_INET6 | ||
kwargs["nodelay"] = True | ||
return cls(cls._connect(host, port, **kwargs)) | ||
|
||
|
||
SocketStream.connect = classmethod(fix_connect) | ||
|
||
|
||
def fix_accept(self): | ||
"""accepts an incoming socket connection (blocking)""" | ||
while self.active: | ||
try: | ||
sock, addrinfo = self.listener.accept() | ||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) | ||
except socket.timeout: | ||
pass | ||
except socket.error: | ||
ex = sys.exc_info()[1] | ||
if get_exc_errno(ex) in (errno.EINTR, errno.EAGAIN): | ||
pass | ||
else: | ||
raise EOFError() | ||
else: | ||
break | ||
|
||
if not self.active: | ||
return | ||
|
||
sock.setblocking(True) | ||
self.logger.info(f"accepted {addrinfo} with fd {sock.fileno()}") | ||
self.clients.add(sock) | ||
self._accept_method(sock) | ||
|
||
|
||
Server.accept = fix_accept |