Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected keyword argument 'no_delay' #1677

Closed
sdmway opened this issue Jul 16, 2024 · 3 comments
Closed

Unexpected keyword argument 'no_delay' #1677

sdmway opened this issue Jul 16, 2024 · 3 comments

Comments

@sdmway
Copy link

sdmway commented Jul 16, 2024

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:[email protected]:3306/pytest?maxsize=20&minsize=5&no_delay=True"

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

@sdmway
Copy link
Author

sdmway commented Jul 16, 2024

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.

@abondar
Copy link
Member

abondar commented Jul 26, 2024

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

Will remove in next release

@abondar
Copy link
Member

abondar commented Aug 17, 2024

Released as 0.21.6

@abondar abondar closed this as completed Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants