def wait(self, timeout=None):
"""
Wait through 'timeout' (in seconds) for a notification, or forever
if it is None. Return True if a notification was received or
False otherwise.
"""
if timeout is not None:
timeout = float(timeout)
while True:
try:
selected = select.select([self.pg], [], [], timeout)
break
except select.error as ex:
err_no, message = ex
if err_no == errno.EINTR:
# TODO: This needs to adjust the time remaining
continue
raise ex
if selected == ([], [], []):
return False
self.pg.poll()
self.__capture_notifications()
return len(self.pending_notifications) > 0
评论列表
文章目录