Skip to content

Commit

Permalink
Implemented poll check as a global.
Browse files Browse the repository at this point in the history
  • Loading branch information
strunker committed Dec 26, 2022
1 parent f0801ce commit 32b7b45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pychromecast/socket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
CONNECTION_STATUS_FAILED_RESOLVE = "FAILED_RESOLVE"
# The socket connection was lost and needs to be retried
CONNECTION_STATUS_LOST = "LOST"
# Check for select poll method
SELECT_HAS_POLL = hasattr(select,"poll")

HB_PING_TIME = 10
HB_PONG_TIME = 10
Expand Down Expand Up @@ -229,8 +231,6 @@ def __init__(

self.receiver_controller.register_status_listener(self)

self.hasSelectPoll = hasattr(select,"poll")

def initialize_connection(
self,
): # pylint:disable=too-many-statements, too-many-branches
Expand Down Expand Up @@ -568,7 +568,7 @@ def run_once(self, timeout=POLL_TIME_NON_BLOCKING):
# poll the socket, as well as the socketpair to allow us to be interrupted
rlist = [self.socket, self.socketpair[0]]
try:
if self.hasSelectPoll == True:
if SELECT_HAS_POLL == True:
# Map file descriptors to socket objects because select.select does not support fd > 1024
# https://stackoverflow.com/questions/14250751/how-to-increase-filedescriptors-range-in-python-select
fd_to_socket = {rlist_item.fileno(): rlist_item for rlist_item in rlist}
Expand Down

0 comments on commit 32b7b45

Please sign in to comment.