async def store(): store = Storage(uri=REDIS_URL, db=1) try: yield store finally: conn = await store.redis() await conn.flushdb() await store.close() await store.wait_closed()
async def on_startup(dispatcher: Dispatcher, **kwargs): logger.debug('setting up services') dispatcher.storage = Storage(REDIS_URL) queue = await arq.create_pool(get_redis_settings()) dispatcher.context_vars.update({ 'storage': dispatcher.storage, 'trakt': TraktClient(), 'queue': (worker_queue_var, queue), }) # setup handlers from traktogram.handlers import auth_router, cmd_router, notification_router, error_router for router in (auth_router, cmd_router, notification_router, error_router): dispatcher.add_router(router) await dispatcher.storage.redis() # test connection
async def on_startup(ctx: dict): NotificationScheduler.send_single_task_name = send_calendar_notifications.__name__ NotificationScheduler.send_multi_task_name = send_calendar_multi_notifications.__name__ ctx['trakt'] = TraktClient() ctx['storage'] = Storage(REDIS_URL) ctx['bot'] = Bot(BOT_TOKEN, parse_mode='html')