shift _check() call to event loop function so read_loop needn't call trigger()

This commit is contained in:
jesopo 2019-06-23 18:53:25 +01:00
parent e88f23e413
commit 9673963a8d

View file

@ -275,7 +275,8 @@ class Bot(object):
self.log.warn("No servers, exiting") self.log.warn("No servers, exiting")
break break
kill = False self._check()
item = self._event_queue.get(block=True, timeout=None) item = self._event_queue.get(block=True, timeout=None)
if item.type == TriggerEventType.Action: if item.type == TriggerEventType.Action:
@ -337,7 +338,6 @@ class Bot(object):
while self.running: while self.running:
events = self._read_poll.poll(self.get_poll_timeout()) events = self._read_poll.poll(self.get_poll_timeout())
self.trigger(self._check, False)
for fd, event in events: for fd, event in events:
if fd == self._rtrigger_server.fileno(): if fd == self._rtrigger_server.fileno():
@ -357,8 +357,9 @@ class Bot(object):
server.disconnect() server.disconnect()
continue continue
self.trigger(self._post_read_factory(server, lines), event_item = TriggerEvent(TriggerEventType.Action,
False) self._post_read_factory(server, lines))
self._event_queue.put(event_item)
elif event & select.POLLHUP: elif event & select.POLLHUP:
self.log.warn("Recieved POLLHUP for %s", [str(server)]) self.log.warn("Recieved POLLHUP for %s", [str(server)])
server.disconnect() server.disconnect()