summaryrefslogtreecommitdiff
path: root/test/base/test_concurrency_py3k.py
Commit message (Collapse)AuthorAgeFilesLines
* fix test suite warningsMike Bayer2023-05-091-3/+10
| | | | | | | | | | | | | | | | fix a handful of warnings that were emitting but not raising, usually because they were inside an "expect_warnings" block. modify "expect_warnings" to always use "raise_on_any_unexpected" behavior; remove this parameter. Fixed issue in semi-private ``await_only()`` and ``await_fallback()`` concurrency functions where the given awaitable would remain un-awaited if the function threw a ``GreenletError``, which could cause "was not awaited" warnings later on if the program continued. In this case, the given awaitable is now cancelled before the exception is thrown. Change-Id: I33668c5e8c670454a3d879e559096fb873b57244
* Allow contextvars to be set in events when using asyncioFederico Caselli2022-04-171-7/+31
| | | | | | | | | Allow setting contextvar values inside async adapted event handlers. Previously the value set to the contextvar would not be properly propagated. Fixes: #7937 Change-Id: I787aa869f8d057579e13e32c749f05f184ffd02a
* establish mypy / typing approach for v2.0Mike Bayer2022-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | large patch to get ORM / typing efforts started. this is to support adding new test cases to mypy, support dropping sqlalchemy2-stubs entirely from the test suite, validate major ORM typing reorganization to eliminate the need for the mypy plugin. * New declarative approach which uses annotation introspection, fixes: #7535 * Mapped[] is now at the base of all ORM constructs that find themselves in classes, to support direct typing without plugins * Mypy plugin updated for new typing structures * Mypy test suite broken out into "plugin" tests vs. "plain" tests, and enhanced to better support test structures where we assert that various objects are introspected by the type checker as we expect. as we go forward with typing, we will add new use cases to "plain" where we can assert that types are introspected as we expect. * For typing support, users will be much more exposed to the class names of things. Add these all to "sqlalchemy" import space. * Column(ForeignKey()) no longer needs to be `@declared_attr` if the FK refers to a remote table * composite() attributes mapped to a dataclass no longer need to implement a `__composite_values__()` method * with_variant() accepts multiple dialect names Change-Id: I22797c0be73a8fbbd2d6f5e0c0b7258b17fe145d Fixes: #7535 Fixes: #7551 References: #6810
* First round of removal of python 2Federico Caselli2021-11-011-5/+1
| | | | | References: #4600 Change-Id: I61e35bc93fe95610ae75b31c18a3282558cd4ffe
* limit greenlet dependency to pypi-listed platformsMike Bayer2021-08-111-1/+3
| | | | | | | | | | | | | | | | | | | | | The setup requirements have been modified such ``greenlet`` is a default requirement only for those platforms that are well known for ``greenlet`` to be installable and for which there is already a pre-built binary on pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other platforms, greenlet will not install by default, which should enable installation and test suite running of SQLAlchemy 1.4 on platforms that don't support ``greenlet``, excluding any asyncio features. In order to install with the ``greenlet`` dependency included on a machine architecture outside of the above list, the ``[asyncio]`` extra may be included by running ``pip install sqlalchemy[asyncio]`` which will then attempt to install ``greenlet``. Additionally, the test suite has been repaired so that tests can complete fully when greenlet is not installed, with appropriate skips for asyncio-related tests. Fixes: #6136 Change-Id: I8f3a1c00a4a8b6a273484af1da1f7aaadf588ae7
* ensure greenlet_spawn propagates BaseExceptionMike Bayer2021-06-181-0/+23
| | | | | | | | | | | Fixed bug in asyncio implementation where the greenlet adaptation system failed to propagate ``BaseException`` subclasses, most notably including ``asyncio.CancelledError``, to the exception handling logic used by the engine to invalidate and clean up the connection, thus preventing connections from being correctly disposed when a task was cancelled. Fixes: #6652 Change-Id: Id3809e6c9e7bced46a7a3b5a0d1906c4168dc4fc
* Make other loop test compatible with py3.10Federico Caselli2021-05-271-11/+12
| | | | | | | | | Python 3.10 fixes the issue where the loop would bind to a queue on instantiation. Now an object binds to the loop only when first needs it. I've looked at queues, but I'm assuming locks behave the same, Change-Id: Ibb8d263cdea230e9c85709528c21da31d0df2e65
* get tests to pass on python 3.10Mike Bayer2021-05-271-4/+10
| | | | | | | | | | | | | | Resolved various deprecation warnings which were appearing as of Python version 3.10.0b1. block aiomysql on python 3.10 as they are using the "loop" argument that's removed sqlcipher-binary has no builds on 3.10, block it for 3.10 Fixes: #6540 Fixes: #6543 Change-Id: Iec1e3881fb289878881ae043b1a18c3ecdf5f077
* Limit AsyncAdaptedQueue to Python 3.7Federico Caselli2021-01-241-0/+4
| | | | | | | | | | | | | | | | | Tests here are failing for python 3.6 due to the lack of asyncio.run(). It seems to be non-trivial to vendor a working version of this in Python 3.6 as the tests here are running it in alternate threads. The python documentation imports everything directly from the asyncio package, and it seems that py < 3.8 does not have the asyncio.exception module Closes: #5865 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5865 Pull-request-sha: 35cc1fa3f6ff962676f571ae30851f4b4d96762a Change-Id: I9398c9fb2aa87f3228ce2f59277de732091bd541
* Merge "Improve error message when await_ call errors"mike bayer2021-01-231-2/+2
|\
| * Improve error message when await_ call errorsFederico Caselli2021-01-211-2/+2
| | | | | | | | | | Fixes: #5832 Change-Id: Ia2ed8f1d1ec54e5f6e1a8f817a69446fdb3b7f6d
* | Fix a couple of bugs in the asyncio implementationFederico Caselli2021-01-211-0/+50
|/ | | | | | | | | | | | | 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
* Repair async test refactorMike Bayer2021-01-021-3/+4
| | | | | | | | | | | | | | | in I4940d184a4dc790782fcddfb9873af3cca844398 we reworked how async tests run but apparently the async tests in test/ext/asyncio are reporting success without being run. This patch pushes pytestplugin further so that it won't instrument any test or function overall that declares itself async. This removes the need for the __async_wrap__ flag and also allows us to use a more strict "run_async_test" function that always runs the asyncio event loop from the top. Also start working asyncio into main testing suite. Change-Id: If7144e951a9db67eb7ea73b377f81c4440d39819
* Support testing of async drivers without fallback modeFederico Caselli2020-12-301-1/+1
| | | | Change-Id: I4940d184a4dc790782fcddfb9873af3cca844398
* Detect non compatible execution in async modeFederico Caselli2020-12-081-0/+13
| | | | | | | | | | The SQLAlchemy async mode now detects and raises an informative error when an non asyncio compatible :term:`DBAPI` is used. Using a standard ``DBAPI`` with async SQLAlchemy will cause it to block like any sync call, interrupting the executing asyncio loop. Change-Id: I9aed87dc1b0df53e8cb2109495237038aa2cb2d4
* Support PEP-567 context variablesFantix King2020-11-191-0/+37
| | | | | | | | | | | | | | | | | | | | | | | Invoke the given function within a copy of the current PEP-567 context in `greenlet_spawn()`, so that subsequent sync methods could retrieve the correct context variable. Adjusted the greenlet integration, which provides support for Python asyncio in SQLAlchemy, to accommodate for the handling of Python ``contextvars`` (introduced in Python 3.7) for ``greenlet`` versions greater than 0.4.17. Greenlet version 0.4.17 added automatic handling of contextvars in a backwards-incompatible way; we've coordinated with the greenlet authors to add a preferred API for this in versions subsequent to 0.4.17 which is now supported by SQLAlchemy's greenlet integration. For greenlet versions prior to 0.4.17 no behavioral change is needed, version 0.4.17 itself is blocked from the dependencies. Fixes: #5615 Closes: #5616 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5616 Pull-request-sha: dcf42f7b78ef3e983fda17f7190cda7b4511e3b4 Change-Id: I378953ee69e1ef2535ba51b97f28cbbbf9de3161
* Implement rudimentary asyncio support w/ asyncpgMike Bayer2020-08-131-0/+103
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