clear _trigger_functions after we've called all the waiting functions

This commit is contained in:
jesopo 2018-10-07 08:06:41 +01:00
parent 6da2a5caa8
commit 29d8549da1

View file

@ -29,9 +29,11 @@ class Bot(object):
self._trigger_functions = [] self._trigger_functions = []
def trigger(self, func=None): def trigger(self, func=None):
self.lock.acquire()
if func: if func:
self._trigger_functions.append(func) self._trigger_functions.append(func)
self._trigger_client.send(b"TRIGGER") self._trigger_client.send(b"TRIGGER")
self.lock.release()
def add_server(self, server_id, connect=True): def add_server(self, server_id, connect=True):
(_, alias, hostname, port, password, ipv4, tls, bindhost, nickname, (_, alias, hostname, port, password, ipv4, tls, bindhost, nickname,
@ -149,6 +151,7 @@ class Bot(object):
for func in self._trigger_functions: for func in self._trigger_functions:
func() func()
self._trigger_functions.clear()
for fd, event in events: for fd, event in events:
sock = None sock = None