Visitar URL original
Correctly shutdown async sessions on exit. by ashb · Pull Request #73838 · apache/airflow · GitHub
Skip to content

Correctly shutdown async sessions on exit. - #73838

Merged
ashb merged 2 commits into
mainfrom
async-orm-disposal
Oct 1, 2026
Merged

ashb merged 2 commits into
mainfrom
async-orm-disposal

Conversation

@ashb

@ashb ashb commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

This isn't "a problem" per se, as the process is about to exit anyway, but this does end up with a confusing/scary looking message in the API server logs of:

^C2026-09-28T12:27:01.066859Z [info     ] Shutting down                  [uvicorn.error] loc=server.py:273
2026-09-28T12:27:01.171309Z [info     ] Waiting for application shutdown. [uvicorn.error] loc=on.py:67
2026-09-28T12:27:01.172064Z [info     ] Application shutdown complete. [uvicorn.error] loc=on.py:76
2026-09-28T12:27:01.172285Z [info     ] Finished server process [1083] [uvicorn.error] loc=server.py:104
2026-09-28T12:27:01.183069Z [error    ] Exception closing connection <AdaptedConnection <aiosqlite.core.Connection object at 0xffff7cac6db0>> [sqlalchemy.pool.impl.AsyncAdaptedQueuePool] loc=base.py:377
Traceback (most recent call last):
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 375, in _close_connection
    self._dialect.do_close(connection)
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 721, in do_close
    dbapi_connection.close()
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 362, in close
    self._handle_exception(error)
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 373, in _handle_exception
    raise error
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 350, in close
    self.await_(self._connection.close())
  File "/usr/python/lib/python3.12/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 123, in await_only
    raise exc.MissingGreenlet(
sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)

This also appears in some unit tests (though only visible when a test fails, as otherwise logs don't get shown), hence the unit test fixture changes


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Comment thread airflow-core/src/airflow/settings.py Resolved
Comment thread airflow-core/src/airflow/settings.py Resolved
@ashb
ashb force-pushed the async-orm-disposal branch from 720f10a to a2fe15e Compare September 30, 2026 21:45
This isn't "a problem" per se, as the process is about to exit anyway, but this does end up with a confusing/scary looking message in the API server logs of:

        Traceback (most recent call last):
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 375, in _close_connection
            self._dialect.do_close(connection)
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 721, in do_close
            dbapi_connection.close()
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 362, in close
            self._handle_exception(error)
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 373, in _handle_exception
            raise error
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 350, in close
            self.await_(self._connection.close())
        File "/usr/python/lib/python3.12/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 123, in await_only
            raise exc.MissingGreenlet(
        sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)

This also appears in some unit tests (though only visible when a test fails, as otherwise logs don't get shown), hence the unit test fixture changes
@ashb
ashb force-pushed the async-orm-disposal branch from a2fe15e to d69e81c Compare October 1, 2026 09:01
Comment thread airflow-core/src/airflow/settings.py Resolved
@ashb
ashb requested a review from amoghrajesh as a code owner October 1, 2026 10:57
@ashb
ashb merged commit bc9ca5b into main Oct 1, 2026
157 checks passed
@ashb
ashb deleted the async-orm-disposal branch October 1, 2026 12:02
@Dev-iL Dev-iL mentioned this pull request Oct 5, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants