My test app runs fine when I use the following:
register_tortoise(
app, db_url="sqlite://:memory:", modules={"models": ["models"]}, generate_schemas=True
)
When I change the database driver to mysql, and run using:
register_tortoise(
app, db_url="mysql://user:pass@host:port/my_db", modules={"models": ["models"]}, generate_schemas=True
)
I get the following console output when attempting to run:
| [2021-10-15 20:48:07 +0000] [1] [INFO] Goin' Fast @ http://0.0.0.0:5000
| INFO:sanic.root:Goin' Fast @ http://0.0.0.0:5000
| DEBUG:tortoise:Tortoise-ORM startup
| connections: {'default': {'engine': 'tortoise.backends.mysql', 'credentials': {'port': 3306, 'charset': 'utf8mb4', 'sql_mode': 'STRICT_TRANS_TABLES', 'database': 'qi_bbms', 'host': '172.12.2.04', 'user': 'qi_bbms', 'password': 'B37P***'}}}
| apps: {'models': {'models': ['models'], 'default_connection': 'default'}}
| [2021-10-15 20:48:09 +0000] [1] [ERROR] Experienced exception while trying to serve
| Traceback (most recent call last):
| File "/usr/local/lib/python3.10/site-packages/sanic/app.py", line 1051, in run
| serve_single(server_settings)
| File "/usr/local/lib/python3.10/site-packages/sanic/server/runners.py", line 199, in serve_single
| serve(**server_settings)
| File "/usr/local/lib/python3.10/site-packages/sanic/server/runners.py", line 126, in serve
| loop.run_until_complete(app._server_event("init", "before"))
| File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
| File "/usr/local/lib/python3.10/site-packages/sanic/app.py", line 1496, in _server_event
| await self.dispatch(
| File "/usr/local/lib/python3.10/site-packages/sanic/signals.py", line 163, in dispatch
| return await dispatch
| File "/usr/local/lib/python3.10/site-packages/sanic/signals.py", line 133, in _dispatch
| retval = await maybe_coroutine
| File "/usr/local/lib/python3.10/site-packages/sanic/app.py", line 1382, in _listener
| await maybe_coro
| File "/usr/local/lib/python3.10/site-packages/tortoise/contrib/sanic/__init__.py", line 82, in init_orm
| await Tortoise.init(config=config, config_file=config_file, db_url=db_url, modules=modules)
| File "/usr/local/lib/python3.10/site-packages/tortoise/__init__.py", line 598, in init
| await cls._init_connections(connections_config, _create_db)
| File "/usr/local/lib/python3.10/site-packages/tortoise/__init__.py", line 390, in _init_connections
| await connection.create_connection(with_db=True)
| File "/usr/local/lib/python3.10/site-packages/tortoise/backends/mysql/client.py", line 114, in create_connection
| self._pool = await mysql.create_pool(password=self.password, **self._template)
| File "/usr/local/lib/python3.10/site-packages/aiomysql/pool.py", line 25, in _create_pool
| pool = Pool(minsize=minsize, maxsize=maxsize, echo=echo,
| File "/usr/local/lib/python3.10/site-packages/aiomysql/pool.py", line 46, in __init__
| self._cond = asyncio.Condition(loop=loop)
| File "/usr/local/lib/python3.10/asyncio/locks.py", line 230, in __init__
| super().__init__(loop=loop)
| File "/usr/local/lib/python3.10/asyncio/mixins.py", line 17, in __init__
| raise TypeError(
| TypeError: As of 3.10, the *loop* parameter was removed from Condition() since it is no longer necessary
| ERROR:sanic.error:Experienced exception while trying to serve
Can anyone assist?
Thank you