-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Labels
Description
Describe the bug
see code to reproduce -
- define async function
- call connection = await aiomysql.connect(...)
- execute some operation (SELECT 1)
- call await connection.close()
- app crashed
To Reproduce
Execute attached python script
Expected behavior
connection.close() should be returning a waitable object for await and not None
Logs/tracebacks
python test-aiomysql-close
2025-07-31 10:53:50,009 INFO : Attempting to connect to maria:3306...
2025-07-31 10:53:50,017 INFO : Successfully connected.
2025-07-31 10:53:50,018 INFO : Dummy query executed successfully.
2025-07-31 10:53:50,018 INFO : Type of conn.close() result (before await): <class 'NoneType'>
2025-07-31 10:53:50,018 INFO : Value of conn.close() result (before await): None
2025-07-31 10:53:50,018 INFO : Attempting to await conn.close()...
2025-07-31 10:53:50,018 ERROR : An error occurred: object NoneType can't be used in 'await' expression
Traceback (most recent call last):
File "/home/phil/temp/test-aiomysql-close", line 42, in test_close_behavior
await close_awaitable
TypeError: object NoneType can't be used in 'await' expressionPython Version
$ python --version
Python 3.12.3aiomysql Version
$ python -m pip show aiomysql
Name: aiomysql
Version: 0.2.0
Summary: MySQL driver for asyncio.
Home-page: https://github.com/aio-libs/aiomysql
Author: Nikolay Novik
Author-email: nickolainovik@gmail.com
License: MIT
Location: /home/phil/dev/archiver/venv/lib/python3.12/site-packages
Requires: PyMySQL
Required-by: async-sqlalchemyPyMySQL Version
$ python -m pip show PyMySQL
Name: PyMySQL
Version: 1.1.1
Summary: Pure Python MySQL Driver
Home-page:
Author:
Author-email: Inada Naoki <songofacandy@gmail.com>, Yutaka Matsubara <yutaka.matsubara@gmail.com>
License: MIT License
Location: /home/phil/dev/archiver/venv/lib/python3.12/site-packages
Requires:
Required-by: aiomysqlSQLAlchemy Version
$ python -m pip show sqlalchemy
Name: SQLAlchemy
Version: 2.0.40
Summary: Database Abstraction Library
Home-page: https://www.sqlalchemy.org
Author: Mike Bayer
Author-email: mike_mp@zzzcomputing.com
License: MIT
Location: /home/phil/dev/archiver/venv/lib/python3.12/site-packages
Requires: greenlet, typing-extensions
Required-by: async-sqlalchemyOS
cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Database type and version
SELECT VERSION();
'10.11.11-MariaDB-0ubuntu0.24.04.2'Additional context
Add code to application to ensure the db is created before sqlalchemy creates tables
Code of Conduct
- I agree to follow the aio-libs Code of Conduct