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:
Luna 2019-04-22 16:27:50 -03:00
parent 5dbf8ac8fd
commit 195a219f75
3 changed files with 14 additions and 4 deletions

View File

@ -56,7 +56,7 @@ class LVSPManager:
# quick storage for Region dataclass instances.
self._regions = {}
self.app.loop.create_task(self._spawn())
self.app.sched.spawn(self._spawn())
async def _spawn(self):
"""Spawn LVSPConnection for each region."""

View File

@ -40,8 +40,12 @@ class FakeApp:
ratelimiter = None
state_manager = None
storage = None
user_storage = None
icons = None
dispatcher = None
presence = None
voice = None
guild_store = None
def init_parser():
@ -76,7 +80,7 @@ def main(config):
# as the managers require it
# and the migrate command also sets the db up
if argv[1] != 'migrate':
init_app_managers(app)
init_app_managers(app, voice=False)
args = parser.parse_args()
loop.run_until_complete(args.func(app, args))

10
run.py
View File

@ -230,7 +230,7 @@ async def init_app_db(app_):
app_.sched = JobManager()
def init_app_managers(app_):
def init_app_managers(app_, *, voice=True):
"""Initialize singleton classes."""
app_.loop = asyncio.get_event_loop()
app_.ratelimiter = RatelimitManager(app_.config.get('_testing'))
@ -246,7 +246,13 @@ def init_app_managers(app_):
app_.storage.presence = app_.presence
app_.voice = VoiceManager(app_)
# 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_.guild_store = GuildMemoryStore()