mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-21 16:00:57 +01:00
relay: bandaid patch for freezes on startup when there are a ton of networks
The side effect of this patch is that it makes large bursts *really* CPU intensive. A proper fix for this will hopefully be introduced in the future.
This commit is contained in:
parent
b7b49769e0
commit
5bffe67416
@ -33,10 +33,7 @@ default_permissions = {"*!*@*": ['relay.linked'],
|
|||||||
def initialize_all(irc):
|
def initialize_all(irc):
|
||||||
"""Initializes all relay channels for the given IRC object."""
|
"""Initializes all relay channels for the given IRC object."""
|
||||||
|
|
||||||
# Wait for all IRC objects to be created first. This prevents
|
def _initialize_all():
|
||||||
# relay servers from being spawned too early (before server authentication),
|
|
||||||
# which would break connections.
|
|
||||||
if world.started.wait(TCONDITION_TIMEOUT):
|
|
||||||
for chanpair, entrydata in db.items():
|
for chanpair, entrydata in db.items():
|
||||||
network, channel = chanpair
|
network, channel = chanpair
|
||||||
|
|
||||||
@ -48,6 +45,14 @@ def initialize_all(irc):
|
|||||||
if network == irc.name:
|
if network == irc.name:
|
||||||
initialize_channel(irc, channel)
|
initialize_channel(irc, channel)
|
||||||
|
|
||||||
|
# Wait for all IRC objects to be created first. This prevents
|
||||||
|
# relay servers from being spawned too early (before server authentication),
|
||||||
|
# which would break connections.
|
||||||
|
if world.started.wait(TCONDITION_TIMEOUT):
|
||||||
|
t = threading.Thread(target=_initialize_all, daemon=True,
|
||||||
|
name='relay initialize_all thread from network %r' % irc.name)
|
||||||
|
t.start()
|
||||||
|
|
||||||
def main(irc=None):
|
def main(irc=None):
|
||||||
"""Main function, called during plugin loading at start."""
|
"""Main function, called during plugin loading at start."""
|
||||||
log.debug('relay.main: loading links database')
|
log.debug('relay.main: loading links database')
|
||||||
@ -500,9 +505,8 @@ def initialize_channel(irc, channel):
|
|||||||
# from the config. Skip this.
|
# from the config. Skip this.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Give each network a tiny bit of leeway to finish up its connection.
|
# Remote net isn't ready yet, try again later.
|
||||||
# This is better than just dropping users their completely.
|
if not remoteirc.connected.is_set():
|
||||||
if not remoteirc.connected.wait(TCONDITION_TIMEOUT):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Join their (remote) users and set their modes, if applicable.
|
# Join their (remote) users and set their modes, if applicable.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user