Closed fervand1 closed 1 year ago
PoolListener was removed in the 1.4 release: #4638 https://docs.sqlalchemy.org/en/20/changelog/changelog_14.html#change-6daf2f59ac2438ef9c8213e9ebeac157
"listeners" is an erroneous documentation artifact that should have been removed.
Mike Bayer has proposed a fix for this issue in the main branch:
remove "listeners" docstring https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4514
Mike Bayer has proposed a fix for this issue in the rel_1_4 branch:
remove "listeners" docstring https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4515
@zzzeek so are the listeners not required anymore in 1.4 for create_engine() since in 1.3 it was working if I upgrade to 1.4 what would be the right way to fix this?
@fervand1 this is why we prefer people start discussions rather than posting bug reports, as expressed in the bug reporting template, since the vast majority of "issues" are actually usage / documentation questions. SQLAlchemy event listeners use the event API. For connection pool events, event hooks documented at PoolEvents should be used.
The PoolListener API should have been emitting a deprecation warning in your program which indicates this, it's been deprecated for about ten years. looks like Python warnings flagneeds to be turned on
from sqlalchemy.interfaces import PoolListener
from sqlalchemy import create_engine
class MyListener(PoolListener):
def connect(self, dbapi_connection, connection_record):
pass
e = create_engine("sqlite://", listeners=[MyListener()])
c = e.connect()
output with -w:
python -Walways test3.py
/home/classic/dev/sqlalchemy/lib/sqlalchemy/pool/impl.py:294: SADeprecationWarning: PoolListener is deprecated in favor of the PoolEvents listener interface. The Pool.listeners parameter will be removed in a future release.
Pool.__init__(self, creator, **kw)
/home/classic/dev/sqlalchemy/lib/sqlalchemy/pool/base.py:229: SADeprecationWarning: The Pool.add_listener() method is deprecated and will be removed in a future release. Please use the PoolEvents listener interface.
self.add_listener(l)
/home/classic/dev/sqlalchemy/lib/sqlalchemy/pool/base.py:290: SADeprecationWarning: PoolListener.connect is deprecated. The PoolListener class will be removed in a future release. Please transition to the @event interface, using @event.listens_for(Engine, 'connect').
interfaces.PoolListener._adapt_listener(self, listener)
Thank you for the information @zzzeek And noted will keep that in mind the next time.
Describe the bug
Hello. I am seeing an issue for create_engine() function where it raises, TypeError: Invalid argument(s) 'listeners' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
In the description of the function I see the param is mentioned in the docstring, but is not handled in the code :param listeners: A list of one or more :class:
~sqlalchemy.interfaces.PoolListener
objects which will receive connection pool events.The same worked on sqlalchemy version 1.3.13 but when I upgrade to 1.4.46 it fails
Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
No response
SQLAlchemy Version in Use
1.4.46
DBAPI (i.e. the database driver)
pysqlite
Database Vendor and Major Version
SQLite
Python Version
3.10
Operating system
Windows
To Reproduce
Error
Additional context
No response