move immediate-write-trigger to IRCServer.py, trigger _event_loop for
running=False
This commit is contained in:
parent
6f27879d1b
commit
f96378ac07
3 changed files with 12 additions and 4 deletions
|
@ -135,7 +135,6 @@ class Module(ModuleManager.BaseModule):
|
|||
|
||||
server.send(utils.irc.protocol.tagmsg(target.name,
|
||||
{"+draft/typing": "active"}), immediate=True)
|
||||
self.bot.trigger()
|
||||
|
||||
module_name = self._get_prefix(hook) or ""
|
||||
if not module_name and hasattr(hook.function, "__self__"):
|
||||
|
|
|
@ -46,8 +46,12 @@ class Bot(object):
|
|||
self._trigger_functions = []
|
||||
self._events.on("timer.reconnect").hook(self._timed_reconnect)
|
||||
|
||||
def _thread_trigger(self):
|
||||
def _trigger_both(self):
|
||||
self.trigger_read()
|
||||
self.trigger_write()
|
||||
def trigger_read(self):
|
||||
self._rtrigger_client.send(b"TRIGGER")
|
||||
def trigger_write(self):
|
||||
self._wtrigger_client.send(b"TRIGGER")
|
||||
|
||||
def trigger(self,
|
||||
|
@ -57,7 +61,7 @@ class Bot(object):
|
|||
|
||||
if utils.is_main_thread():
|
||||
returned = func()
|
||||
self._thread_trigger()
|
||||
self._trigger_both()
|
||||
return returned
|
||||
|
||||
func_queue = queue.Queue(1) # type: queue.Queue[str]
|
||||
|
@ -74,7 +78,7 @@ class Bot(object):
|
|||
|
||||
type, returned = func_queue.get(block=True)
|
||||
|
||||
self._thread_trigger()
|
||||
self._trigger_both()
|
||||
|
||||
if type == TriggerResult.Exception:
|
||||
raise returned
|
||||
|
@ -262,6 +266,7 @@ class Bot(object):
|
|||
while self.running:
|
||||
if not self.servers:
|
||||
self.running = False
|
||||
self._event_queue.put(lambda: None)
|
||||
break
|
||||
|
||||
events = self._read_poll.poll(self.get_poll_timeout())
|
||||
|
|
|
@ -255,6 +255,10 @@ class Server(IRCObject.Object):
|
|||
line_obj = IRCLine.SentLine(line_events, datetime.datetime.utcnow(),
|
||||
self.hostmask(), line_parsed)
|
||||
self.socket.send(line_obj, immediate=immediate)
|
||||
|
||||
if immediate:
|
||||
self.bot.trigger_write()
|
||||
|
||||
return line_obj
|
||||
def send_raw(self, line: str):
|
||||
return self.send(utils.irc.parse_line(line))
|
||||
|
|
Loading…
Reference in a new issue