Skip to content

Commit 031d38c

Browse files
authored
Revert "Revert "Remove socket timeouts"" (#883)
1 parent da31460 commit 031d38c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pychromecast/socket_client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969

7070
HB_PING_TIME = 10
7171
HB_PONG_TIME = 10
72-
POLL_TIME_BLOCKING = 5.0
73-
POLL_TIME_NON_BLOCKING = 0.01
7472
TIMEOUT_TIME = 30.0
7573
RETRY_TIME = 5.0
7674

@@ -530,7 +528,7 @@ def run(self) -> None:
530528
self.logger.debug("Thread started...")
531529
while not self.stop.is_set():
532530
try:
533-
if self._run_once(timeout=POLL_TIME_BLOCKING) == 1:
531+
if self._run_once() == 1:
534532
break
535533
except Exception: # pylint: disable=broad-except
536534
self._force_recon = True
@@ -545,7 +543,7 @@ def run(self) -> None:
545543
# Clean up
546544
self._cleanup()
547545

548-
def _run_once(self, timeout: float = POLL_TIME_NON_BLOCKING) -> int:
546+
def _run_once(self) -> int:
549547
"""Receive from the socket and handle data."""
550548
# pylint: disable=too-many-branches, too-many-statements, too-many-return-statements
551549

@@ -569,10 +567,10 @@ def _run_once(self, timeout: float = POLL_TIME_NON_BLOCKING) -> int:
569567
poll_obj = select.poll()
570568
for poll_fd in rlist:
571569
poll_obj.register(poll_fd, select.POLLIN)
572-
poll_result = poll_obj.poll(timeout * 1000) # timeout in milliseconds
570+
poll_result = poll_obj.poll()
573571
can_read = [fd_to_socket[fd] for fd, _status in poll_result]
574572
else:
575-
can_read, _, _ = select.select(rlist, [], [], timeout)
573+
can_read, _, _ = select.select(rlist, [], [], None)
576574
except (ValueError, OSError) as exc:
577575
self.logger.error(
578576
"[%s(%s):%s] Error in select call: %s",

0 commit comments

Comments
 (0)