From c0f4959ed766b6b6341f315d3c3f33848468b16a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Aug 2013 14:19:09 -0400 Subject: [PATCH] Change long timeout to select() from poll() Change from poll() to select() for the potentially long wait in ipmi event loop. This is to facilitate interop with being monkey patched with eventlet, as eventlet does not currently monkey patch poll(), but does monkey patch select() Change-Id: I8d6f42193ee82e2c5de7ad112232c2c77ef78825 --- pyghmi/ipmi/private/session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index e765472d..dcc32366 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -165,6 +165,7 @@ class Session: curmax = cls.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) cls.poller.register(cls.socket, select.POLLIN) + cls.readersockets = [cls.socket] cls.ipmipoller.register(cls.socket, select.POLLIN) curmax = curmax / 2 # we throttle such that we never have no more outstanding packets than @@ -637,7 +638,8 @@ class Session: # could be waiting so we can always return 0 if timeout is None: return 0 - if cls.poller.poll(timeout * 1000): + rdylist, _, _ = select.select(cls.readersockets, (), (), timeout) + if len(rdylist) > 0: while cls.ipmipoller.poll(0): # if the somewhat lengthy queue # processing takes long enough for packets to come in, # be eager @@ -698,6 +700,7 @@ class Session: will receive the handle as an argument """ cls._external_handlers[handle.fileno()] = (callback, handle) + cls.readersockets += [handle] cls.poller.register(handle, select.POLLIN) @classmethod