@app.listener('before_server_stop')
async def teardown(context, loop):
    context.run_retrain = False
    context.executor.shutdown()
    context.pool.close()
    (await context.pool.wait_closed())
@app.listener('before_server_stop')
async def teardown(context, loop):
    context.run_retrain = False
    context.executor.shutdown()
    context.pool.close()
    (await context.pool.wait_closed())