Use .trigger (without triggering read/write threads) to call _check

This commit is contained in:
jesopo 2019-06-06 23:23:46 +01:00
parent 24ca7ed97f
commit 6d44f12193

View file

@ -65,12 +65,13 @@ class Bot(object):
self._wtrigger_client.send(b"TRIGGER")
def trigger(self,
func: typing.Optional[typing.Callable[[], typing.Any]]=None
) -> typing.Any:
func: typing.Optional[typing.Callable[[], typing.Any]]=None,
trigger_threads=True) -> typing.Any:
func = func or (lambda: None)
if utils.is_main_thread():
returned = func()
if trigger_threads:
self._trigger_both()
return returned
@ -88,6 +89,7 @@ class Bot(object):
type, returned = func_queue.get(block=True)
if trigger_threads:
self._trigger_both()
if type == TriggerResult.Exception:
@ -277,12 +279,13 @@ class Bot(object):
def _read_loop(self):
while self.running:
print("read loop")
if not self.servers:
self.running = False
self._event_queue.put(lambda: None)
break
self._event_queue.put(self._check)
self.trigger(self._check, False)
events = self._read_poll.poll(self.get_poll_timeout())