Check availability of poll method before using

When eventlet is monkey patched, select.poll is removed since
it is not thread safe. So check availability of `poll` method
before using it.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2022-06-30 11:52:52 +05:30
parent 3165e80ee5
commit 13c4c7662e

View File

@ -179,7 +179,7 @@ class WSClient:
# efficient as epoll. Will work for fd numbers above 1024.
# select.epoll() - newest and most efficient way of polling.
# However, only works on linux.
if sys.platform.startswith('linux') or sys.platform in ['darwin']:
if hasattr(select, "poll"):
poll = select.poll()
poll.register(self.sock.sock, select.POLLIN)
r = poll.poll(timeout)