Skip to content

Commit

Permalink
Bypass user timeout for Mac TCP stack
Browse files Browse the repository at this point in the history
  • Loading branch information
danijar committed Nov 13, 2024
1 parent 7c50a21 commit 2e91e04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.5.0'
__version__ = '3.5.1'

import multiprocessing as mp
try:
Expand Down
7 changes: 4 additions & 3 deletions portal/client_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ def _create(self):
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, after)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, every)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, fails)
sock.setsockopt(
socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT,
1000 * (after + every * fails))
if hasattr(socket, 'TCP_USER_TIMEOUT'): # Linux
sock.setsockopt(
socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT,
1000 * (after + every * fails))
if sys.platform == 'darwin':
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPALIVE, every)
Expand Down

0 comments on commit 2e91e04

Please sign in to comment.