tortoise/tortoise-orm

Unexpected keyword argument 'no_delay'

sdmway opened this issue · 3 comments

Describe the bug

Cannot use the no_delay parameter in the database URL to disable Nagle’s algorithm on the socket.

To Reproduce

Use Tortoise.init() with a db_url containing the parameter no_delay set to True.

Expected behavior

Disabling Nagle’s algorithm on the socket.

Additional context

Ignoring exception in on_connect
Traceback (most recent call last):
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/nextcord/client.py", line 497, in run_event
await coro(*args, **kwargs)
File "/Users/clownidze/Developer/setlvl/setlvl-discord/main.py", line 27, in on_connect
await start_database()
File "/Users/clownidze/Developer/setlvl/setlvl-discord/src/database/base.py", line 35, in start_database
await Tortoise.generate_schemas()
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/init.py", line 577, in generate_schemas
await generate_schema_for_client(connection, safe)
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/utils.py", line 43, in generate_schema_for_client
await generator.generate_from_string(schema)
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/base/schema_generator.py", line 476, in generate_from_string
await self.client.execute_script(creation_string)
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/mysql/client.py", line 44, in translate_exceptions

return await func(self, *args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/mysql/client.py", line 212, in execute_script
async with self.acquire_connection() as connection:
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/base/client.py", line 326, in aenter
await self.ensure_connection()
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/base/client.py", line 322, in ensure_connection
await self.client.create_connection(with_db=True)
File "/Users/clownidze/Library/Caches/pypoetry/virtualenvs/setlvl-discord-zuc0O9kV-py3.11/lib/python3.11/site-packages/tortoise/backends/mysql/client.py", line 115, in create_connection
self._pool = await mysql.create_pool(password=self.password, **self._template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "asyncmy/pool.pyx", line 216, in _create_pool
File "asyncmy/pool.pyx", line 217, in asyncmy.pool._create_pool
File "asyncmy/pool.pyx", line 145, in fill_free_pool
File "asyncmy/connection.pyx", line 1278, in asyncmy.connection.connect
TypeError: connect() got an unexpected keyword argument 'no_delay'

        if db_url:
            if not modules:
                raise ConfigurationError('You must specify "db_url" and "modules" together')
            config = generate_config(db_url, modules)
            print(config)

Output of print(config):

{'connections': {'default': {'engine': 'tortoise.backends.mysql', 'credentials': {'port': 3306, 'charset': 'utf8mb4', 'sql_mode': 'STRICT_TRANS_TABLES', 'maxsize': 20, 'minsize': 5, 'no_delay': True, 'database': 'pytest', 'host': '127.0.0.1', 'user': 'test', 'password': 'test'}}}, 'apps': {'models': {'models': ['src.database.models'], 'default_connection': 'default'}}}

Database URL I am trying to connect with: "mysql://test:test@127.0.0.1:3306/pytest?maxsize=20&minsize=5&no_delay=True"

Param described in docs: https://tortoise.github.io/databases.html?h=no_delay#id6

asyncmy accepts unix_socket param. If no unix_socket provided, no_delay is automatically set to true

https://github.com/long2ice/asyncmy/blob/dev/asyncmy/connection.pyx#L157
https://github.com/long2ice/asyncmy/blob/dev/asyncmy/connection.pyx#L570

Therefore, it's better to remove the no_delay parameter from the documentation.

Yeah, seems it was removed 2 years ago from aiomysql too

Will remove in next release

Released as 0.21.6