summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/pool
Commit message (Collapse)AuthorAgeFilesLines
* provide connectionfairy on initializeMike Bayer2021-11-293-52/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is so that dialect methods that are called within init can assume the same argument structure as when they are called in other places; we can nail down the type of object as well. This change seems to mostly impact the isolation level routines in the dialects, as these are called during initialize() as well as on established connections. these methods can now assume a non-proxied DBAPI connection object in all cases, as it is commonly required that attributes like ".autocommit" are set on the object which don't work well in a proxied situation. Other changes: * adds an interface for the "connectionfairy" concept called PoolProxiedConnection. * Removes ``Connectable`` superclass of Connection. ``Connectable`` was originally meant to provide for the "method which accepts connection or engine" theme. As this pattern is greatly reduced in 2.0 and Engine no longer extends from it, the ``Connectable`` superclass doesnt serve any real purpose. Leading from that, to set this in I also applied pep 484 annotations to the Dialect base, and then in the interests of seeing some of the typing information show up in my IDE did a little bit for Engine, Connection and others. I hope that it's feasible that we can add annotations to specific classes and attributes ahead of when we actually try to mass-populate the whole library. This was the original spirit of pep-484 that we can apply annotations gradually. I do of course want to try to do a mass-populate although i think even in that case we will end up doing a lot of manual work anyway (in particular for the changes here which are distinct from what the stubs have). Fixes: #7122 Change-Id: I5dd7fbff8a7ae520a81c165091af12a6a68826db
* Remove object in class definitionFederico Caselli2021-11-222-4/+4
| | | | | References: #4600 Change-Id: I2a62ddfe00bc562720f0eae700a497495d7a987a
* De-emphasize notion of "default driver" (DBAPI)Gord Thompson2021-11-091-2/+2
| | | | | | | | | | | Fixes: #6960 Even though a default driver still exists for each dialect, remove most usages of `dialect://` to encourage users to explicitly specify `dialect+driver://` Change-Id: I0ad42167582df509138fca64996bbb53e379b1af
* fully implement future engine and remove legacyMike Bayer2021-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The major action here is to lift and move future.Connection and future.Engine fully into sqlalchemy.engine.base. This removes lots of engine concepts, including: * autocommit * Connection running without a transaction, autobegin is now present in all cases * most "autorollback" is obsolete * Core-level subtransactions (i.e. MarkerTransaction) * "branched" connections, copies of connections * execution_options() returns self, not a new connection * old argument formats, distill_params(), simplifies calling scheme between engine methods * before/after_execute() events (oriented towards compiled constructs) don't emit for exec_driver_sql(). before/after_cursor_execute() is still included for this * old helper methods superseded by context managers, connection.transaction(), engine.transaction() engine.run_callable() * ancient engine-level reflection methods has_table(), table_names() * sqlalchemy.testing.engines.proxying_engine References: #7257 Change-Id: Ib20ed816642d873b84221378a9ec34480e01e82c
* Surface driver connection object when using a proxied dialectFederico Caselli2021-09-173-60/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | Improve the interface used by adapted drivers, like the asyncio ones, to access the actual connection object returned by the driver. The :class:`_engine._ConnectionRecord` and :class:`_engine._ConnectionFairy` now have two new attributes: * ``dbapi_connection`` always represents a DBAPI compatible object. For pep-249 drivers, this is the DBAPI connection as it always has been, previously accessed under the ``.connection`` attribute. For asyncio drivers that SQLAlchemy adapts into a pep-249 interface, the returned object will normally be a SQLAlchemy adaption object called :class:`_engine.AdaptedConnection`. * ``driver_connection`` always represents the actual connection object maintained by the third party pep-249 DBAPI or async driver in use. For standard pep-249 DBAPIs, this will always be the same object as that of the ``dbapi_connection``. For an asyncio driver, it will be the underlying asyncio-only connection object. The ``.connection`` attribute remains available and is now a legacy alias of ``.dbapi_connection``. Fixes: #6832 Change-Id: Ib72f97deefca96dce4e61e7c38ba430068d6a82e
* Replace all http:// links to https://Federico Caselli2021-07-045-5/+5
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Propagate asyncio flag from the dialect to selected pool classesFederico Caselli2021-06-082-7/+12
| | | | | | | | | Fixed an issue that presented itself when using the :class:`_pool.NullPool` or the :class:`_pool.StaticPool` with an async engine. This mostly affected the aiosqlite dialect. Fixes: #6575 Change-Id: Ic1e27d99ffcb20ed4de82ea78f430a0f3b629d86
* Add new "sync once" mode for pool.connectMike Bayer2021-04-211-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed critical regression caused by the change in :ticket`5497` where the connection pool "init" phase no longer occurred within mutexed isolation, allowing other threads to proceed with the dialect uninitialized, which could then impact the compilation of SQL statements. This issue is essentially the same regression which was fixed many years ago in :ticket:`2964` in dd32540dabbee0678530fb1b0868d1eb41572dca, which was missed this time as the test suite fo that issue only tested the pool in isolation, and assumed the "first_connect" event would be used by the Engine. However :ticket:`5497` stopped using "first_connect" and no test detected the lack of mutexing, that has been resolved here through the addition of more tests. This fix also identifies what is probably a bug in earlier versions of SQLAlchemy where the "first_connect" handler would be cancelled if the initializer failed; this is evidenced by test_explode_in_initializer which was doing a reconnect due to c.rollback() yet wasn't hanging. We now solve this issue by preventing the manufactured Connection from ever reconnecting inside the first_connect handler. Also remove the "_sqla_unwrap" test attribute; this is almost not used anymore however we can use a more targeted wrapper supplied by the testing.engines.proxying_engine function. See if we can also open up Oracle for "ad hoc engines" tests now that we have better connection management logic. Fixes: #6337 Change-Id: I4a3476625c4606f1a304dbc940d500325e8adc1a
* Add support for aiosqliteFederico Caselli2021-03-242-12/+30
| | | | | | | | Added support for the aiosqlite database driver for use with the SQLAlchemy asyncio extension. Fixes: #5920 Change-Id: Id11a320516a44e886a6f518d2866a0f992413e55
* Merge "Ignore flake8 F401 on specific files"mike bayer2021-03-071-4/+4
|\
| * Ignore flake8 F401 on specific filesFederico Caselli2021-03-031-4/+4
| | | | | | | | | | | | | | | | Uses the flake8 option per-file-ignores that was introduced in a recent version of flake8 (3.7.+) to avoid having lots of "noqa" in import only files Change-Id: Ib4871d63bad7e578165615df139cbf6093479201
* | Replace reset_agent with direct call from connectionMike Bayer2021-03-061-64/+31
|/ | | | | | | | | | | | | Fixed a regression where the "reset agent" of the connection pool wasn't really being utilized by the :class:`_engine.Connection` when it were closed, and also leading to a double-rollback scenario that was somewhat wasteful. The newer architecture of the engine has been updated so that the connection pool "reset-on-return" logic will be skipped when the :class:`_engine.Connection` explicitly closes out the transaction before returning the pool to the connection. Fixes: #6004 Change-Id: I5d2ac16cac71aa45a00b4b7481d7268bd828a168
* Fix a couple of bugs in the asyncio implementationFederico Caselli2021-01-212-8/+31
| | | | | | | | | | | | | Log an informative message if a connection is not closed and the gc is reclaiming it when using an async dpapi, that does not support running IO at that stage. The ``AsyncAdaptedQueue`` used by default on async dpapis should instantiate a queue only when it's first used to avoid binding it to a possibly wrong event loop. Fixes: #5823 Change-Id: Ibfc50e209b1937ae3d6599ae7997f028c7a92c33
* Create explicit GC ordering between ConnectionFairy/ConnectionRecordMike Bayer2021-01-151-9/+40
| | | | | | | | | | | | | | Fixed issue where connection pool would not return connections to the pool or otherwise be finalized upon garbage collection under pypy if the checked out connection fell out of scope without being closed. This is a long standing issue due to pypy's difference in GC behavior that does not call weakref finalizers if they are relative to another object that is also being garbage collected. A strong reference to the related record is now maintained so that the weakref has a strong-referenced "base" to trigger off of. Fixes: #5842 Change-Id: Id5448fdacb6cceaac1ea40b2fbc851f052ed8e86
* reinvent xdist hooks in terms of pytest fixturesMike Bayer2021-01-131-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To allow the "connection" pytest fixture and others work correctly in conjunction with setup/teardown that expects to be external to the transaction, remove and prevent any usage of "xdist" style names that are hardcoded by pytest to run inside of fixtures, even function level ones. Instead use pytest autouse fixtures to implement our own r"setup|teardown_test(?:_class)?" methods so that we can ensure function-scoped fixtures are run within them. A new more explicit flow is set up within plugin_base and pytestplugin such that the order of setup/teardown steps, which there are now many, is fully documented and controllable. New granularity has been added to the test teardown phase to distinguish between "end of the test" when lock-holding structures on connections should be released to allow for table drops, vs. "end of the test plus its teardown steps" when we can perform final cleanup on connections and run assertions that everything is closed out. From there we can remove most of the defensive "tear down everything" logic inside of engines which for many years would frequently dispose of pools over and over again, creating for a broken and expensive connection flow. A quick test shows that running test/sql/ against a single Postgresql engine with the new approach uses 75% fewer new connections, creating 42 new connections total, vs. 164 new connections total with the previous system. As part of this, the new fixtures metadata/connection/future_connection have been integrated such that they can be combined together effectively. The fixture_session(), provide_metadata() fixtures have been improved, including that fixture_session() now strongly references sessions which are explicitly torn down before table drops occur afer a test. Major changes have been made to the ConnectionKiller such that it now features different "scopes" for testing engines and will limit its cleanup to those testing engines corresponding to end of test, end of test class, or end of test session. The system by which it tracks DBAPI connections has been reworked, is ultimately somewhat similar to how it worked before but is organized more clearly along with the proxy-tracking logic. A "testing_engine" fixture is also added that works as a pytest fixture rather than a standalone function. The connection cleanup logic should now be very robust, as we now can use the same global connection pools for the whole suite without ever disposing them, while also running a query for PostgreSQL locks remaining after every test and assert there are no open transactions leaking between tests at all. Additional steps are added that also accommodate for asyncio connections not explicitly closed, as is the case for legacy sync-style tests as well as the async tests themselves. As always, hundreds of tests are further refined to use the new fixtures where problems with loose connections were identified, largely as a result of the new PostgreSQL assertions, many more tests have moved from legacy patterns into the newest. An unfortunate discovery during the creation of this system is that autouse fixtures (as well as if they are set up by @pytest.mark.usefixtures) are not usable at our current scale with pytest 4.6.11 running under Python 2. It's unclear if this is due to the older version of pytest or how it implements itself for Python 2, as well as if the issue is CPU slowness or just large memory use, but collecting the full span of tests takes over a minute for a single process when any autouse fixtures are in place and on CI the jobs just time out after ten minutes. So at the moment this patch also reinvents a small version of "autouse" fixtures when py2k is running, which skips generating the real fixture and instead uses two global pytest fixtures (which don't seem to impact performance) to invoke the "autouse" fixtures ourselves outside of pytest. This will limit our ability to do more with fixtures until we can remove py2k support. py.test is still observed to be much slower in collection in the 4.6.11 version compared to modern 6.2 versions, so add support for new TOX_POSTGRESQL_PY2K and TOX_MYSQL_PY2K environment variables that will run the suite for fewer backends under Python 2. For Python 3 pin pytest to modern 6.2 versions where performance for collection has been improved greatly. Includes the following improvements: Fixed bug in asyncio connection pool where ``asyncio.TimeoutError`` would be raised rather than :class:`.exc.TimeoutError`. Also repaired the :paramref:`_sa.create_engine.pool_timeout` parameter set to zero when using the async engine, which previously would ignore the timeout and block rather than timing out immediately as is the behavior with regular :class:`.QueuePool`. For asyncio the connection pool will now also not interact at all with an asyncio connection whose ConnectionFairy is being garbage collected; a warning that the connection was not properly closed is emitted and the connection is discarded. Within the test suite the ConnectionKiller is now maintaining strong references to all DBAPI connections and ensuring they are released when tests end, including those whose ConnectionFairy proxies are GCed. Identified cx_Oracle.stmtcachesize as a major factor in Oracle test scalability issues, this can be reset on a per-test basis rather than setting it to zero across the board. the addition of this flag has resolved the long-standing oracle "two task" error problem. For SQL Server, changed the temp table style used by the "suite" tests to be the double-pound-sign, i.e. global, variety, which is much easier to test generically. There are already reflection tests that are more finely tuned to both styles of temp table within the mssql test suite. Additionally, added an extra step to the "dropfirst" mechanism for SQL Server that will remove all foreign key constraints first as some issues were observed when using this flag when multiple schemas had not been torn down. Identified and fixed two subtle failure modes in the engine, when commit/rollback fails in a begin() context manager, the connection is explicitly closed, and when "initialize()" fails on the first new connection of a dialect, the transactional state on that connection is still rolled back. Fixes: #5826 Fixes: #5827 Change-Id: Ib1d05cb8c7cf84f9a4bfd23df397dc23c9329bfe
* happy new yearMike Bayer2021-01-045-5/+5
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Support testing of async drivers without fallback modeFederico Caselli2020-12-302-0/+6
| | | | Change-Id: I4940d184a4dc790782fcddfb9873af3cca844398
* QueuePool: support subsecond timeoutJordan Pittier2020-11-211-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: #5719 <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description Make it explicit in the documentation and in the default value for the 'timeout' parameter that `timeout` can be a float. Because Python timing is not very accurate, warn about the precision. ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [x] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #5710 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5710 Pull-request-sha: 5f4eef8b4aba756d32e14ea41f71ef2919c26b84 Change-Id: I462524b1624ca5cc76d083a1d58e5dc89501c1a9
* Support pool.connect() event firing before all elseMike Bayer2020-11-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where a connection pool event specified with a keyword, most notably ``insert=True``, would be lost when the event were set up. This would prevent startup events that need to fire before dialect-level events from working correctly. The internal mechanics of the engine connection routine has been altered such that it's now guaranteed that a user-defined event handler for the :meth:`_pool.PoolEvents.connect` handler, when established using ``insert=True``, will allow an event handler to run that is definitely invoked **before** any dialect-specific initialization starts up, most notably when it does things like detect default schema name. Previously, this would occur in most cases but not unconditionally. A new example is added to the schema documentation illustrating how to establish the "default schema name" within an on-connect event (upcoming as part of I882edd5bbe06ee5b4d0a9c148854a57b2bcd4741) Addiional changes to support setting default schema name: The Oracle dialect now uses ``select sys_context( 'userenv', 'current_schema' ) from dual`` to get the default schema name, rather than ``SELECT USER FROM DUAL``, to accommodate for changes to the session-local schema name under Oracle. Added a read/write ``.autocommit`` attribute to the DBAPI-adaptation layer for the asyncpg dialect. This so that when working with DBAPI-specific schemes that need to use "autocommit" directly with the DBAPI connection, the same ``.autocommit`` attribute which works with both psycopg2 as well as pg8000 is available. Fixes: #5716 Fixes: #5708 Change-Id: I7dce56b4345ffc720e25e2aaccb7e42bb29e5671
* generalize scoped_session proxying and apply to asyncio elementsMike Bayer2020-10-101-0/+1
| | | | | | | | | | | | | | | | | | | | Reworked the proxy creation used by scoped_session() to be based on fully copied code with augmented docstrings and moved it into langhelpers. asyncio session, engine, connection can now take advantage of it so that all non-async methods are availble. Overall implementation of most important accessors / methods on AsyncConnection, etc. , including awaitable versions of invalidate, execution_options, etc. In order to support an event dispatcher on the async classes while still allowing them to hold __slots__, make some adjustments to the event system to allow that to be present, at least rudimentally. Fixes: #5628 Change-Id: I5eb6929fc1e4fdac99e4b767dcfd49672d56e2b2
* Revert "Use monotonic time for pool age measurement"Mike Bayer2020-10-071-9/+17
| | | | | | | | | | This reverts commit 0220b58917b5a979891b5765f6ac5095e0368489. I completely misread https://www.python.org/dev/peps/pep-0418/#rationale and the accuracy of monotonic() is *worse* on windows than time.time(), which is bizarre. Change-Id: I2d571e268a2051bea68736507773d3904403af9e
* Use monotonic time for pool age measurementMike Bayer2020-10-071-17/+9
| | | | | | | | | | | | | The internal clock used by the :class:`_pool.Pool` object is now time.monotonic_time() under Python 3. Under Python 2, time.time() is still used, which is legacy. This clock is used to measure the age of a connection against its starttime, and used in comparisons against the pool_timeout setting as well as the last time the pool was marked as invalid to determine if the connection should be recycled. Previously, time.time() was used which was subject to inaccuracies as a result of system clock changes as well as poor time resolution on windows. Change-Id: I94f90044c1809508e26a5a00134981c2a00d0405
* Merge "Pass all pool parameters in recreate()"mike bayer2020-09-141-0/+8
|\
| * Pass all pool parameters in recreate()Mike Bayer2020-09-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | The following pool parameters were not being propagated to the new pool created when :meth:`_engine.Engine.dispose` were called: ``pre_ping``, ``use_lifo``. Additionally the ``recycle`` and ``reset_on_return`` parameters were not propagated for the :class:`_engine.AssertionPool` class. These issues have been fixed. Fixes: #5582 Change-Id: Ifdb703aa7e849652242b9ff8071c854cd1d77e71
* | Adapt event exec_once_mutex to asyncioMike Bayer2020-09-143-0/+9
|/ | | | | | | | | The pool makes use of a threading.Lock() for the "first_connect" event. if the pool is async make sure this is a greenlet-adapted asyncio lock. Fixes: #5581 Change-Id: If52415839c7ed82135465f1fe93b95d86c305820
* Implement rudimentary asyncio support w/ asyncpgMike Bayer2020-08-132-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Using the approach introduced at https://gist.github.com/zzzeek/6287e28054d3baddc07fa21a7227904e We can now create asyncio endpoints that are then handled in "implicit IO" form within the majority of the Core internals. Then coroutines are re-exposed at the point at which we call into asyncpg methods. Patch includes: * asyncpg dialect * asyncio package * engine, result, ORM session classes * new test fixtures, tests * some work with pep-484 and a short plugin for the pyannotate package, which seems to have so-so results Change-Id: Idbcc0eff72c4cad572914acdd6f40ddb1aef1a7d Fixes: #3414
* Assert reset agent always set correctly and is activeMike Bayer2020-05-131-2/+18
| | | | | | | | | | | | | | | | | | | | Fixed fairly critical issue where the DBAPI connection could be returned to the connection pool while still in an un-rolled-back state. The reset agent responsible for rolling back the connection could be corrupted in the case that the transaction was "closed" without being rolled back or committed, which can occur in some scenarios when using ORM sessions and emitting .close() in a certain pattern involving savepoints. The fix ensures that the reset agent is always active. note that the reset agent will go away in 2.0 and the only real purpose of it is for logging of ROLLBACK. Apparently with the SQLite singleton engine in the test suite, there are some strucutral mismatches in the test fixtures where the reset agent is getting set differently than the transaction likely due to the same connection being shared in multiple context, though it's unclear. Fixes: #5326 Change-Id: If056870ea70a2d9a1749768988d5e023f3061b31
* Set up absolute references for create_engine and relatedMike Bayer2020-04-142-7/+8
| | | | | | | includes more replacements for create_engine(), Connection, disambiguation of Result from future/baked Change-Id: Icb60a79ee7a6c45ea9056c211ffd1be110da3b5e
* Run search and replace of symbolic module namesMike Bayer2020-04-143-40/+49
| | | | | | | | Replaces a wide array of Sphinx-relative doc references with an abbreviated absolute form now supported by zzzeeksphinx. Change-Id: I94bffcc3f37885ffdde6238767224296339698a2
* Ensure all nested exception throws have a causeMike Bayer2020-03-021-2/+2
| | | | | | | | | | | | | | | Applied an explicit "cause" to most if not all internally raised exceptions that are raised from within an internal exception catch, to avoid misleading stacktraces that suggest an error within the handling of an exception. While it would be preferable to suppress the internally caught exception in the way that the ``__suppress_context__`` attribute would, there does not as yet seem to be a way to do this without suppressing an enclosing user constructed context, so for now it exposes the internally caught exception as the cause so that full information about the context of the error is maintained. Fixes: #4849 Change-Id: I55a86b29023675d9e5e49bc7edc5a2dc0bcd4751
* Don't call pre_ping for fresh connectionMike Bayer2020-02-261-11/+21
| | | | | | | | | | The pool "pre-ping" feature has been refined to not invoke for a DBAPI connection that was just opened in the same checkout operation. pre ping only applies to a DBAPI connection that's been checked into the pool and is being checked out again. Fixes: #4524 Change-Id: Ibe3dfb709dbdc24aa94e96513cfbea456c33b895
* Do away with pool._refsMike Bayer2020-02-012-7/+0
| | | | | | | | | | | | | This collection was added only for the benefit of unit tests and is unnecessary for the pool to function. As SQLAlchemy 2.0 will be removing the automatic handling of connections that are garbage collection, remove this collection so that we ultimately don't need a weakref handler to do anything within the pool. The handler will do nothing other than emit a warning that a connection was dereferenced without being explicitly returned to the pool, invalidated, or detached. Change-Id: I4ca196270d5714efbac44dbf6f034e8c7f0af58a
* Reorganize core event modules to avoid import cyclesMike Bayer2020-01-212-0/+237
| | | | | | | | | sqlalchemy.sql.naming was causing a full import of engine due to the DDLEvents dependency. Break out pool, DDL and engine events into new modules specific to those packages; resolve some other import cycles in Core also. Change-Id: Ife8d217e58a26ab3605dd80ee70837968f957eaf
* Merge "Use context managers for threading.Lock()"mike bayer2020-01-031-4/+1
|\
| * Use context managers for threading.Lock()Heckad2020-01-031-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | (zzzeek:) For some reason I thought that threading.Lock() still did not support context managers, at least in Python 2, however this does not seem to be the case. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #5069 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5069 Pull-request-sha: efeac06dda5afdbe33abcf9b27c8b5b5725c8444 Change-Id: Ic64fcd99cd587bc70b4ecc5b45d8205b5c76eff2
* | happy new yearMike Bayer2020-01-014-4/+4
|/ | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Note time passage requirement for pool.invalidate()Mike Bayer2019-12-271-0/+13
| | | | | | | | | | | | | | | | | | For Windows, time.time() may only have 16 millisecond accuracy, so invalidation routines which compare the time.time() of invalidate() to the time.time() when the ConnectionRecord last connected may fail in a unit test environment that does not pause at least this much time since the ConnectionRecord startup. Using >= for comparison instead of > was considered but this only leads to more confusing results as the ConnecitonRecord goes into a re-connect loop as time continues to not pass. Overall, while using routines such as Python 3.7's time_ns() might be helpful, for now make sure tests which rely on this are marked under timing intensive and add small sleeps. Change-Id: I1a7162e67912d22c135fa517b687a073f8fd9151
* Remove deprecated extension and similar classesMike Bayer2019-10-061-35/+0
| | | | | | | | | | All long-deprecated "extension" classes have been removed, including MapperExtension, SessionExtension, PoolListener, ConnectionProxy, AttributExtension. These classes have been deprecated since version 0.7 long superseded by the event listener system. Fixes: #4638 Change-Id: If4156d4956b10847bd93b6408a7c52ff5168db9b
* Add new "exec_once_unless_exception" system; apply to dialect.initializeMike Bayer2019-08-181-1/+1
| | | | | | | | | | | | | | | | | | Fixed an issue whereby if the dialect "initialize" process which occurs on first connect would encounter an unexpected exception, the initialize process would fail to complete and then no longer attempt on subsequent connection attempts, leaving the dialect in an un-initialized, or partially initialized state, within the scope of parameters that need to be established based on inspection of a live connection. The "invoke once" logic in the event system has been reworked to accommodate for this occurrence using new, private API features that establish an "exec once" hook that will continue to allow the initializer to fire off on subsequent connections, until it completes without raising an exception. This does not impact the behavior of the existing ``once=True`` flag within the event system. Fixes: #4807 Change-Id: Iec32999b61b6af4b38b6719e0c2651454619078c
* Rewrite pool reset_on_return parsing using a util functionMike Bayer2019-08-111-10/+10
| | | | | | | | Choosing a util.symbol() based on a user parameter is about to have another use case added as part of #4623, so add a generalized solution ahead of it. Change-Id: I420631f81af2ffc655995b9cce9ff2ac618c16d7
* Remove threadlocal engine strategy, engine strategies pool threadlocalMike Bayer2019-07-152-49/+4
| | | | | | | | | | | | The "threadlocal" execution strategy, deprecated in 1.3, has been removed for 1.4, as well as the concept of "engine strategies" and the ``Engine.contextual_connect`` method. The "strategy='mock'" keyword argument is still accepted for now with a deprecation warning; use :func:`.create_mock_engine` instead for this use case. Fixes: #4632 Change-Id: I8a351f9fa1f7dfa2a56eec1cd2d1a4b9d65765a2 (cherry picked from commit b368c49b44c5716d93c7428ab22b6761c6ca7cf5)
* Improve documentation for connection pool loggingjaskiratsingh2019-04-051-5/+14
| | | | | | | | | | | | | | Also do a general pass for logging + doc formatting, add more cross-linking and remove obsolete information such as "echo_uow"/ Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #4571 Closes: #4583 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4583 Pull-request-sha: e98ad34eca7e9f59fb07cd8b7ec317c1cb989848 Change-Id: I03f7354a4ef55fd8b6a51d03a280579f36e8a06c
* Restore use_threadlocal equivalent behavior to SingletonThreadPoolMike Bayer2019-04-031-0/+21
| | | | | | | | | | | | | | | | | | Fixed behavioral regression as a result of deprecating the "use_threadlocal" flag for :class:`.Pool`, where the :class:`.SingletonThreadPool` no longer makes use of this option which causes the "rollback on return" logic to take place when the same :class:`.Engine` is used multiple times in the context of a transaction to connect or implicitly execute, thereby cancelling the transaction. While this is not the recommended way to work with engines and connections, it is nonetheless a confusing behavioral change as when using :class:`.SingletonThreadPool`, the transaction should stay open regardless of what else is done with the same engine in the same thread. The ``use_threadlocal`` flag remains deprecated however the :class:`.SingletonThreadPool` now implements its own version of the same logic. Fixes: #4585 Change-Id: I906293f2d0a5d14ed46cd9e64305a6481505a5a3
* Fix many spell glitchesLele Gaifax2019-01-251-1/+1
| | | | | | | | | | | | This affects mostly docstrings, except in orm/events.py::dispose_collection() where one parameter gets renamed: given that the method is empty, it seemed reasonable to me to fix that too. Closes: #4440 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4440 Pull-request-sha: 779ed75acb6142e1f1daac467b5b14134529bb4b Change-Id: Ic0553fe97853054b09c2453af76d96363de6eb0e
* Merge "Provide public accessor for Pool.timeout()."mike bayer2019-01-241-0/+3
|\
| * Provide public accessor for Pool.timeout().Irina Delamare2019-01-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Added public accessor :meth:`.Pool.timeout` that returns the configured timeout for a :class:`.Pool` object. Pull request courtesy Irina Delamare. Fixes: #3689 Closes: #4447 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4447 Pull-request-sha: 0179b0a829e9609429dc698992670d2e6749c10c Change-Id: I402b065cf9183160f71d9de73e308268356b7deb
* | Add deprecation warnings to all deprecated APIsMike Bayer2019-01-233-46/+26
|/ | | | | | | | | | | | | | | A large change throughout the library has ensured that all objects, parameters, and behaviors which have been noted as deprecated or legacy now emit ``DeprecationWarning`` warnings when invoked. As the Python 3 interpreter now defaults to displaying deprecation warnings, as well as that modern test suites based on tools like tox and pytest tend to display deprecation warnings, this change should make it easier to note what API features are obsolete. See the notes added to the changelog and migration notes for further details. Fixes: #4393 Change-Id: If0ea11a1fc24f9a8029352eeadfc49a7a54c0a1b
* Convert most "See also" phrases into .. seealso::Mike Bayer2019-01-151-1/+3
| | | | | Change-Id: Ie32598b895c1c5f5bce7c8e1573abbcfe9d434a8 (cherry picked from commit e81d3815abb36c52b0019dee6e4f67990e3d1c7d)
* Remove version directives for 0.6, 0.7, 0.8Mike Bayer2019-01-151-9/+0
| | | | | | | | | - fix a few "seealso"s - ComparableProprerty's "superseded in 0.7" becomes deprecated in 0.7 Backport to currently maintained doc versions 1.2, 1.1 Change-Id: Ib1fcb2df8673dbe5c4ffc47f3896a60d1dfcb4b2
* Merge "use ..deprecated directive w/ version in all cases"mike bayer2019-01-121-7/+16
|\