summaryrefslogtreecommitdiff
path: root/tests/test_asyncio
Commit message (Collapse)AuthorAgeFilesLines
* fix: do not use asyncio's timeout lib before 3.11.2 (#2659)Thiago Bellini Ribeiro2023-03-281-1/+3
| | | | | | | | | | | | There's an issue in asyncio's timeout lib before 3.11.3 that causes async calls to raise `CancelledError`. This is a cpython issue that was fixed in this commit [1] and cherry-picked to previous versions, meaning 3.11.3 will work correctly. Check [2] for more info. [1] https://github.com/python/cpython/commit/04adf2df395ded81922c71360a5d66b597471e49 [2] https://github.com/redis/redis-py/issues/2633
* AsyncIO Race Condition Fix (#2641)v4.5.3Chayim2023-03-222-0/+38
|
* Fix behaviour of async PythonParser to match RedisParser as for issue #2349 ↵Kristján Valur Jónsson2023-03-161-2/+0
| | | | | | | (#2582) * Allow data to drain from PythonParser after connection close. * Add Changes
* fix: replace async_timeout by asyncio.timeout (#2602)Mehdi ABAAKOUK2023-03-161-9/+13
| | | | | | | | | | | | | async_timeout does not support python 3.11 https://github.com/aio-libs/async-timeout/pull/295 And have two years old annoying bugs: https://github.com/aio-libs/async-timeout/issues/229 https://github.com/redis/redis-py/issues/2551 Since asyncio.timeout has been shipped in python 3.11, we should start using it. Partially fixes 2551
* update json().arrindex() default values (#2611)Alex Schmitz2023-03-151-3/+9
| | | | | | | | | | | | | | | | | * update json().arrindex() default values * add unit test * fix falsy checks * more unit tests * add asyncio tests * fix lint line length --------- Co-authored-by: Alex Schmitz <aschmitz@box.com>
* Fix issue 2349: Let async HiredisParser finish parsing after a ↵Kristján Valur Jónsson2023-02-061-0/+82
| | | | | | | | | | | | | Connection.disconnect() (#2557) * A failing unittest * Do not clear the redis-reader's state when we disconnect so that it can finish reading the final message * Test that reading a message of two chunks after a disconnect() works. * Add Changes * fix typos
* Fix issue 2540: Synchronise concurrent command calls to single-client mode. ↵Vivanov982023-01-291-0/+45
| | | | | (#2568) Co-authored-by: Viktor Ivanov <viktor@infogrid.io>
* Add support to BF.CARD (#2545)shacharPash2023-01-111-0/+15
| | | | | | | * Add support to BF.CARD * Add Async test * change to with pytest.raises
* Make PythonParser resumable (#2510)Kristján Valur Jónsson2023-01-052-7/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | * PythonParser is now resumable if _stream IO is interrupted * Add test for parse resumability * Clear PythonParser state when connection or parsing errors occur. * disable test for cluster mode. * Perform "closed" check in a single place. * Update tests * Simplify code. * Remove reduntant test, EOF is detected inside _readline() * Make syncronous PythonParser restartable on error, same as HiredisParser Fix sync PythonParser * Add CHANGES * isort * Move MockStream and MockSocket into their own files
* replase get_event_loop wite get_running_loop (#2530)dvora-h2023-01-053-15/+15
|
* Add dialect to ft aggregate (#2537)DvirDukhan2023-01-021-71/+98
| | | | | | | | | * add dialect to aggregate request * added test * format * async test
* Add TIMEOUT to query class (#2519)shacharPash2022-12-211-0/+9
| | | | | | | | | | | | | | | | | | | * add timeout to query class * Add test_timeout * fix lines * fix format * add test & fixes * merge tests * change timeout to not_a_number * change q1 to q2 * Fix async method
* Combine auto-concatenated strings (#2482)David Gilman2022-12-145-10/+10
|
* Updating graph tests to support new execution plan (#2486)Raz Monsonego2022-12-061-9/+5
|
* Updating dev dependencies (#2475)Chayim2022-12-041-2/+4
|
* Async: added 'blocking' argument to call lock method (#2454)Sibuken2022-12-011-0/+8
| | | Co-authored-by: Chayim <chayim@users.noreply.github.com>
* Added a replacement for the default cluster node in the event of failure. ↵Bar Shaul2022-12-011-0/+40
| | | | (#2463)
* Failover handling improvements for RedisCluster and Async RedisCluster (#2377)Bar Shaul2022-11-102-2/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Cluster&AsyncCluster: Removed handling of timeouts/connection errors within the cluster loop, fixed "cannot pickle '_thread.lock' object" bug, added client's side failover handling improvements * Fixed linters * Type fixes * Added to CHANGES * Added getter and setter for the client's retry object and added more tests * Fixed linters * Fixed test * Fixed test_client_kill test * Changed get_default_backoff to default_backoff, removed retry_on_error and connection_error_retry_attempts from RedisCluster, default retry changed to no retries * Fixing linters * Reverting deletion of connection_error_retry_attempts to maintain backward compatibility * Updating retry object for existing and new connections * Changed the default value of reinitialize_steps from 10 to 5 * fix review comments Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: dvora-h <dvora.heller@redis.com> Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* CredentialsProvider class added to support password rotation (#2261)Bar Shaul2022-11-101-0/+284
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * A CredentialsProvider class has been added to allow the user to add his own provider for password rotation * Moved CredentialsProvider to a separate file, added type hints * Changed username and password to properties * Added: StaticCredentialProvider, examples, tests Changed: CredentialsProvider to CredentialProvider Fixed: calling AUTH only with password * Changed private members' prefix to __ * fixed linters * fixed auth test * fixed credential test * Raise an error if username or password are passed along with credential_provider * fixing linters * fixing test * Changed dundered to single per side underscore * Changed Connection class members username and password to properties to enable backward compatibility with changing the members value on existing connection. * Reverting last commit and adding backward compatibility to 'username' and 'password' inside on_connect function * Refactored CredentialProvider class * Fixing tuple type to Tuple * Fixing optional string members in UsernamePasswordCredentialProvider * Fixed credential test * Added credential provider support to AsyncRedis * linters * linters * linters * linters - black Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> Co-authored-by: dvora-h <dvora.heller@redis.com>
* Fix special response parsing options handling (#2302)Shay Fadida2022-11-091-1/+11
| | | | | | | | | | | | | | | | | * Fix special response parsing options handling When using special response parsing options like `NEVER_DECODE` and `EMPTY_RESPONSE`, don't pass them to the response callbacks because some of them are not prepared for receiving named arguments. Instead, redis-py should use them before calling the callbacks and then discard them. * Use kwargs instead of options * change options to kwargs in asyncio/cluster.py/L878 Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Enable AsyncIO cluster mode lock (#2446)Milhan2022-11-091-1/+0
| | | Co-authored-by: Chayim <chayim@users.noreply.github.com>
* Remove the superflous SocketBuffer from asyncio PythonParser (#2418)Kristján Valur Jónsson2022-10-301-4/+5
| | | | | | | | | | | * Remove buffering from asyncio SocketBuffer and rely on on the underlying StreamReader * Skip the use of SocketBuffer in PythonParser * Remove SocketBuffer altogether * Code cleanup * Fix unittest mocking when SocketBuffer is gone
* Fix KeyError in async cluster - initialize before execute multi key commands ↵dvora-h2022-10-301-0/+9
| | | | | | | | | (#2439) * Fix KeyError in async cluster * link to issue * typo
* Fixing bloom tests (#2430)Chayim2022-10-251-3/+3
|
* Deprecate `add_doccument` (FT.ADD) (#2425)dvora-h2022-10-241-163/+78
| | | | | | | | | * deprecate add_doccuments * linters * linters * async tests
* Fix `TIMESERIES` (round floats) and `JSON` tests (#2421)dvora-h2022-10-232-2/+2
| | | | | * Fix timeseries tests (round floats) * fix json tests
* remove tdigest.add weights (#2408)dvora-h2022-10-061-18/+18
|
* Simplify async timeouts and allowing `timeout=None` in ↵v4.4.0rc2Kristján Valur Jónsson2022-09-291-1/+1
| | | | | | | | | | | | | | | | | | | `PubSub.get_message()` to wait forever (#2295) * Avoid an extra "can_read" call and use timeout directly. * Remove low-level read timeouts from the Parser, now handled in the Connection * Allow pubsub.get_message(time=None) to block. * update Changes * increase test timeout for robustness * expand with statement to avoid invoking null context managers. remove nullcontext * Remove unused import
* Dev/no can read (#2360)Kristján Valur Jónsson2022-09-293-6/+6
| | | | | | | | * make can_read() destructive for simplicity, and rename the method. Remove timeout argument, always timeout immediately. * don't use can_read in pubsub * connection.connect() now has its own retry, don't need it inside a retry loop
* Add `nowait` flag to `asyncio.Connection.disconnect()` (#2356)Kristján Valur Jónsson2022-09-291-30/+43
| | | | | | | | | | | | | | * Don't wait for disconnect() when handling errors. This can result in other errors such as timeouts. * add CHANGES * Update redis/asyncio/connection.py Co-authored-by: Aarni Koskela <akx@iki.fi> * await a task to try to diagnose unittest failures in CI Co-authored-by: Aarni Koskela <akx@iki.fi>
* Catch `Exception` and not `BaseException` in the `Connection` (#2104)Kristján Valur Jónsson2022-09-291-0/+74
| | | | | | | * Add failing unittests for passing BaseException through * Resolve failing unittest * Remove redundant checks for asyncio.CancelledError
* Dev/no lock (#2308)Kristján Valur Jónsson2022-09-282-26/+26
| | | | | * Remove async lock in asyncio.Connection.read_response * Skip concurrent-commands test on non-pooled connections
* Add support for new TDIGEST features and changes (#2392)dvora-h2022-09-211-21/+78
| | | | | | | | | | | * Add support to TDIGEST * linters * linters * linters * disable View Test Results in CI
* fixing async test for module list (#2367)Chayim2022-09-071-1/+2
|
* Mark `TOPK.COUNT` as deprecated (#2363)dvora-h2022-09-041-6/+8
| | | | | * deprecate * linters
* fix test (#2358)dvora-h2022-08-251-0/+3
|
* Add BITFIELD_RO (#2340)Alibi2022-08-211-0/+13
|
* Fix GRAPH.LIST & TDIGEST.QUANTILE tests (#2335)dvora-h2022-08-142-7/+7
| | | | | | | | | * fix graph list_keys test * async test * fix tdigest.quantile * fix
* Add support for WITHSUFFIXTRIE to FT.CREATE (#2324)v4.4.0rc1dvora-h2022-08-041-0/+24
| | | | | | | * withsuffixtrie * Update test_search.py * fix
* Search test - Ignore order of the items in the response (#2322)dvora-h2022-08-041-1/+1
| | | | | * fix test * async test
* Support TDIGEST.MERGESTORE and make compression optional on TDIGEST.CREATE ↵dvora-h2022-08-021-0/+13
| | | | | | | | | | | (#2319) * support 2.4 * async test * skip tests * linters
* Fix async SEARCH pipeline (#2316)dvora-h2022-08-021-1/+20
| | | | | * fix search async pipeline * newline
* Replace `ensure_future` with `create_task` (#2311)dvora-h2022-08-021-5/+1
| | | | | * Replace `ensure_future` with `create_task` * linters
* Add support for `TDIGEST.QUANTILE` extensions (#2317)dvora-h2022-08-021-9/+19
| | | | | | | | | * Add support for TDIGEST.QUANTILE extensions * linters * linters & utils * Update test_bloom.py
* Fix timezone handling for datetime to unixtime conversions (#2213)joe2022-08-021-4/+3
| | | | | | | | | | | | | | * Fix timezone handling for datetime to unixtime conversions datetime objects are supported to set expire, these can have timezones. mktime was used to convert these to unixtime. mktime in Python however is not timezone aware, it expects the input to be UTC and redis-py did not convert the datetime timestamps to UTC before calling mktime. This can lead to: 1) Setting incorrect expire times because the input datetime object has a timezone but is passed to mktime without converting to UTC first. 2) When the datetime timestamp is within DST, mktime fails with "OverflowError: mktime argument out of range" because UTC doesn't have DST. This depends on libc versions. * linters Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Add support for async GRAPH module (#2273)dvora-h2022-07-281-0/+503
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add support for async graph * linters * fix docstring * Use retry mechanism in async version of Connection objects (#2271) * fix is_connected (#2278) * fix: workaround asyncio bug on connection reset by peer (#2259) Fixes #2237 * Fix crash: key expire while search (#2270) * fix expire while search * sleep * docs: Fix a few typos (#2274) * docs: Fix a few typos There are small typos in: - redis/cluster.py - redis/commands/core.py - redis/ocsp.py - tests/test_cluster.py Fixes: - Should read `validity` rather than `valididy`. - Should read `reinitialize` rather than `reinitilize`. - Should read `farthest` rather than `farest`. - Should read `commands` rather than `comamnds`. * Update core.py * async_cluster: fix concurrent pipeline (#2280) - each pipeline should create separate stacks for each node * Add support for TIMESERIES 1.8 (#2296) * Add support for timeseries 1.8 * fix info * linters * linters * fix info test * type hints * linters * Remove verbose logging from `redis-py/redis/cluster.py` (#2238) * removed the logging module and its corresponding methods * updated CHANGES * except block for RedisClusterException and BusyLoadingError removed * removed unused import (redis.exceptions.BusyLoadingError) * empty commit to re-trigger Actions workflow * replaced BaseException with Exception * empty commit to re-trigger Actions workflow * empty commit to re-trigger Actions workflow * redundant logic removed * re-trigger pipeline * reverted changes * re-trigger pipeline * except logic changed * redis stream example (#2269) * redis stream example * redis stream example on docs/examples.rst Co-authored-by: pedro.frazao <perl.pf@netcf.org> * Fix: `start_id` type for `XAUTOCLAIM` (#2257) * Changed start_id type for xautoclaim * Added to changes Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> * Doc add timeseries example (#2267) * DOC add timeseries example * DOC add timeseries examples * Apply suggestions * Fix typo Detention period => Retention period Co-authored-by: Gauthier Imbert <gauthier@PC17> * Fix warnings and resource usage problems in asyncio unittests (#2258) * Use pytest-asyncio in auto mode Remove overly genereric `pytestmark=pytest.mark.asyncio` causing lots of warning noise * Use "Factories as Fixtures" test pattern for the `create_redis` fixture this fixture is now async, avoiding teardown problems with missing event loops. * Fix sporadic error on fast event loops, such as `--uvloop` * Close connection, even if "username" was in kwargs This fixes a resource usage warning in the async unittests. * Do async cleanup of acl passwords via a fixture * Remove unused import, fix whitespace * Fix test with missing "await" * Close pubsub objects after use in unittest Use a simple fixture where possible, otherwise manually call pubsub.close() * re-introduce `pytestmark=pytest.mark.asyncio` for python 3.6 * Use context manager to clean up connections in connection pool for unit tests * Provide asynccontextmanager for python 3.6 * make `test_late_subscribe()` more robuste * Catch a couple of additional leaked resources * Graph - add counters for removed labels and properties (#2292) * grpah - add counters for removed labels and properties * added mock graph result set statistics * docstrings for graph result set statistics * format * isort * moved docstrings into functions * cleaning up the readme and moving docs into readthedocs (#2291) * cleaning up the readme and moving docs into readthedocs * examples at the end as per pr comments * async_cluster: fix max_connections/ssl & improve args (#2217) * async_cluster: fix max_connections/ssl & improve args - set proper connection_class if ssl = True - pass max_connections/connection_class to ClusterNode - recreate startup_nodes to properly initialize - pass parser_class to Connection instead of changing it in on_connect - only pass redis_connect_func if read_from_replicas = True - add connection_error_retry_attempts parameter - skip is_connected check in acquire_connection as it is already checked in send_packed_command BREAKING: - RedisCluster args except host & port are kw-only now - RedisCluster will no longer accept unknown arguments - RedisCluster will no longer accept url as an argument. Use RedisCluster.from_url - RedisCluster.require_full_coverage defaults to True - ClusterNode args except host, port, & server_type are kw-only now * async_cluster: remove kw-only requirement from client Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> * fix review comments * fix * fix review comments * fix review comments Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: szumka <106675199+szumka@users.noreply.github.com> Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net> Co-authored-by: Tim Gates <tim.gates@iress.com> Co-authored-by: Utkarsh Gupta <utkarshgupta137@gmail.com> Co-authored-by: Nial Daly <34862917+nialdaly@users.noreply.github.com> Co-authored-by: pedrofrazao <603718+pedrofrazao@users.noreply.github.com> Co-authored-by: pedro.frazao <perl.pf@netcf.org> Co-authored-by: Антон Безденежных <gamer392@yandex.ru> Co-authored-by: Iglesys <g.imbert34@gmail.com> Co-authored-by: Gauthier Imbert <gauthier@PC17> Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com> Co-authored-by: DvirDukhan <dvir@redis.com>
* automatically reconnect pubsub when reading messages in blocking mode (#2281)Kristján Valur Jónsson2022-07-272-1/+138
| | | | | | | | | | | | | | | | * optimistic default info on test sessionstart. Makes test discovery work, even without a redis connection. * Add unittests verifying that (non-async) PubSub will automatically reconnect * Add tests for asyncio pubsub subsciription auto-reconnect * automatically connect for blocking reads (asyncio) * fix automatic connect on blocking pubsub read (non-async) * lint & format * Perform `connect()` call in PubSub code rather than `read_response`.
* Drop python 3.6 support (#2306)dvora-h2022-07-2715-120/+14
|
* async_cluster: fix max_connections/ssl & improve args (#2217)Utkarsh Gupta2022-07-271-32/+178
| | | | | | | | | | | | | | | | | | | | | | * async_cluster: fix max_connections/ssl & improve args - set proper connection_class if ssl = True - pass max_connections/connection_class to ClusterNode - recreate startup_nodes to properly initialize - pass parser_class to Connection instead of changing it in on_connect - only pass redis_connect_func if read_from_replicas = True - add connection_error_retry_attempts parameter - skip is_connected check in acquire_connection as it is already checked in send_packed_command BREAKING: - RedisCluster args except host & port are kw-only now - RedisCluster will no longer accept unknown arguments - RedisCluster will no longer accept url as an argument. Use RedisCluster.from_url - RedisCluster.require_full_coverage defaults to True - ClusterNode args except host, port, & server_type are kw-only now * async_cluster: remove kw-only requirement from client Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Fix warnings and resource usage problems in asyncio unittests (#2258)Kristján Valur Jónsson2022-07-2616-275/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use pytest-asyncio in auto mode Remove overly genereric `pytestmark=pytest.mark.asyncio` causing lots of warning noise * Use "Factories as Fixtures" test pattern for the `create_redis` fixture this fixture is now async, avoiding teardown problems with missing event loops. * Fix sporadic error on fast event loops, such as `--uvloop` * Close connection, even if "username" was in kwargs This fixes a resource usage warning in the async unittests. * Do async cleanup of acl passwords via a fixture * Remove unused import, fix whitespace * Fix test with missing "await" * Close pubsub objects after use in unittest Use a simple fixture where possible, otherwise manually call pubsub.close() * re-introduce `pytestmark=pytest.mark.asyncio` for python 3.6 * Use context manager to clean up connections in connection pool for unit tests * Provide asynccontextmanager for python 3.6 * make `test_late_subscribe()` more robuste * Catch a couple of additional leaked resources