mirror of https://gitlab.com/litecord/litecord.git
add ability to purposefully disable voice initialization
there is an issue (not very urgent) where a traceback was shown at any `manage.py` usage. this was not catched before because of recent modifications that removed manager startup when calling `migrate`.
This commit is contained in:
parent
5dbf8ac8fd
commit
195a219f75
|
|
@ -56,7 +56,7 @@ class LVSPManager:
|
||||||
# quick storage for Region dataclass instances.
|
# quick storage for Region dataclass instances.
|
||||||
self._regions = {}
|
self._regions = {}
|
||||||
|
|
||||||
self.app.loop.create_task(self._spawn())
|
self.app.sched.spawn(self._spawn())
|
||||||
|
|
||||||
async def _spawn(self):
|
async def _spawn(self):
|
||||||
"""Spawn LVSPConnection for each region."""
|
"""Spawn LVSPConnection for each region."""
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,12 @@ class FakeApp:
|
||||||
ratelimiter = None
|
ratelimiter = None
|
||||||
state_manager = None
|
state_manager = None
|
||||||
storage = None
|
storage = None
|
||||||
|
user_storage = None
|
||||||
|
icons = None
|
||||||
dispatcher = None
|
dispatcher = None
|
||||||
presence = None
|
presence = None
|
||||||
|
voice = None
|
||||||
|
guild_store = None
|
||||||
|
|
||||||
|
|
||||||
def init_parser():
|
def init_parser():
|
||||||
|
|
@ -76,7 +80,7 @@ def main(config):
|
||||||
# as the managers require it
|
# as the managers require it
|
||||||
# and the migrate command also sets the db up
|
# and the migrate command also sets the db up
|
||||||
if argv[1] != 'migrate':
|
if argv[1] != 'migrate':
|
||||||
init_app_managers(app)
|
init_app_managers(app, voice=False)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
loop.run_until_complete(args.func(app, args))
|
loop.run_until_complete(args.func(app, args))
|
||||||
|
|
|
||||||
8
run.py
8
run.py
|
|
@ -230,7 +230,7 @@ async def init_app_db(app_):
|
||||||
app_.sched = JobManager()
|
app_.sched = JobManager()
|
||||||
|
|
||||||
|
|
||||||
def init_app_managers(app_):
|
def init_app_managers(app_, *, voice=True):
|
||||||
"""Initialize singleton classes."""
|
"""Initialize singleton classes."""
|
||||||
app_.loop = asyncio.get_event_loop()
|
app_.loop = asyncio.get_event_loop()
|
||||||
app_.ratelimiter = RatelimitManager(app_.config.get('_testing'))
|
app_.ratelimiter = RatelimitManager(app_.config.get('_testing'))
|
||||||
|
|
@ -246,7 +246,13 @@ def init_app_managers(app_):
|
||||||
|
|
||||||
app_.storage.presence = app_.presence
|
app_.storage.presence = app_.presence
|
||||||
|
|
||||||
|
# only start VoiceManager if needed.
|
||||||
|
# we do this because of a bug on ./manage.py where it
|
||||||
|
# cancels the LVSPManager's spawn regions task. we don't
|
||||||
|
# need to start it on manage time.
|
||||||
|
if voice:
|
||||||
app_.voice = VoiceManager(app_)
|
app_.voice = VoiceManager(app_)
|
||||||
|
|
||||||
app_.guild_store = GuildMemoryStore()
|
app_.guild_store = GuildMemoryStore()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue