summaryrefslogtreecommitdiff
path: root/redis/asyncio/connection.py
Commit message (Collapse)AuthorAgeFilesLines
* Optionally disable disconnects in read_response (#2695)Kristján Valur Jónsson2023-05-081-10/+18
| | | | | | | | | | | | | * Add regression tests and fixes for issue #1128 * Fix tests for resumable read_response to use "disconnect_on_error" * undo prevision fix attempts in async client and cluster * re-enable cluster test * Suggestions from code review * Add CHANGES
* asyncio: Fix memory leak caused by hiredis (#2693) (#2694)Oran Avraham2023-04-131-3/+4
|
* 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
* Fix behaviour of async PythonParser to match RedisParser as for issue #2349 ↵Kristján Valur Jónsson2023-03-161-13/+11
| | | | | | | (#2582) * Allow data to drain from PythonParser after connection close. * Add Changes
* fix: replace async_timeout by asyncio.timeout (#2602)Mehdi ABAAKOUK2023-03-161-8/+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
* Speeding up the protocol parsing (#2596)Chayim2023-03-151-13/+12
| | | | | | | * speeding up the protocol parser * linting * changes to ease
* Fix issue with `pack_commands` returning an empty byte sequence (#2416)jmcbailey2023-02-071-1/+2
| | | Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Fix issue 2349: Let async HiredisParser finish parsing after a ↵Kristján Valur Jónsson2023-02-061-6/+9
| | | | | | | | | | | | | 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
* Make PythonParser resumable (#2510)Kristján Valur Jónsson2023-01-051-18/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-051-1/+1
|
* Failover handling improvements for RedisCluster and Async RedisCluster (#2377)Bar Shaul2022-11-101-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 docs for password protected socket access (#2378)Robert Hofer2022-11-071-1/+1
| | | Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Remove the superflous SocketBuffer from asyncio PythonParser (#2418)Kristján Valur Jónsson2022-10-301-133/+37
| | | | | | | | | | | * 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: catch OSError on asyncio (#2412)송형근(Hyeongguen Song)/DnU2022-10-251-2/+2
|
* Simplify async timeouts and allowing `timeout=None` in ↵v4.4.0rc2Kristján Valur Jónsson2022-09-291-91/+47
| | | | | | | | | | | | | | | | | | | `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-291-31/+20
| | | | | | | | * 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-10/+11
| | | | | | | | | | | | | | * 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-5/+3
| | | | | | | * 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-281-35/+0
| | | | | * Remove async lock in asyncio.Connection.read_response * Skip concurrent-commands test on non-pooled connections
* Handle auth errors for newer versions of Redis. (#2325) (#2329)Luca Cillario2022-08-301-0/+11
|
* Drop python 3.6 support (#2306)dvora-h2022-07-271-17/+8
|
* fix: workaround asyncio bug on connection reset by peer (#2259)Mehdi ABAAKOUK2022-07-241-1/+10
| | | Fixes #2237
* fix is_connected (#2278)dvora-h2022-07-211-1/+1
|
* Use retry mechanism in async version of Connection objects (#2271)szumka2022-07-211-1/+5
|
* Fix retries in async mode (#2180)Eric Lemoine2022-06-191-0/+17
| | | | | | | | | * Avoid mutating a global retry_on_error list * Make retries config consistent in sync and async * Fix async retries * Add new TestConnectionConstructorWithRetry tests
* update black to 22.3.0 (#2171)Utkarsh Gupta2022-05-301-1/+1
|
* async_cluster: add/update typing (#2195)Utkarsh Gupta2022-05-301-4/+4
| | | | | | | * async_cluster: add/update typing * async_cluster: update cleanup_kwargs with kwargs from async Connection * async_cluster: properly remove old nodes
* Add Async RedisCluster (#2099)Utkarsh Gupta2022-05-081-57/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Copy Cluster Client, Commands, Commands Parser, Tests for asyncio * Async Cluster Tests: Async/Await * Add Async RedisCluster * cluster: use ERRORS_ALLOW_RETRY from self.__class__ * async_cluster: rework redis_connection, initialize, & close - move redis_connection from NodesManager to ClusterNode & handle all related logic in ClusterNode class - use Locks while initializing or closing - in case of error, close connections instead of instantly reinitializing - create ResourceWarning instead of manually deleting client object - use asyncio.gather to run commands/initialize/close in parallel - inline single use functions - fix test_acl_log for py3.6 * async_cluster: add types * async_cluster: add docs * docs: update sphinx & add sphinx_autodoc_typehints * async_cluster: move TargetNodesT to cluster module * async_cluster/commands: inherit commands from sync class if possible * async_cluster: add benchmark script with aredis & aioredis-cluster * async_cluster: remove logging * async_cluster: inline functions * async_cluster: manage Connection instead of Redis Client * async_cluster/commands: optimize parser * async_cluster: use ensure_future & generators for gather * async_conn: optimize * async_cluster: optimize determine_slot * async_cluster: optimize determine_nodes * async_cluster/parser: optimize _get_moveable_keys * async_cluster: inlined check_slots_coverage * async_cluster: update docstrings * async_cluster: add concurrent test & use read_response/_update_moved_slots without lock Co-authored-by: Chayim <chayim@users.noreply.github.com>
* Replace OSError exceptions from `can_read` with `redis.ConnectionError` (#2140)Kristján Valur Jónsson2022-05-081-1/+7
| | | | | | | * Replace OSError exceptions from `can_read` with `redis.ConnectionError` * Fix formatting * Revert unintended formatting change
* always clear reference to closed reader/writer (#2077)Bea Steers2022-04-041-2/+3
| | | | | * always clear reference to reader/writer * add #2065 to changes
* Add support to use certificates from string in ssl connection (#2048)dvora-h2022-03-141-2/+11
| | | | | | | | | * ssl string cert * fix async test * linters * change test name
* redis_connect_func (#2046)Lazaros Toumanidis2022-03-141-0/+2
|
* Add Async Support (#1899)Andrew Chen Wang2022-02-221-0/+1707
Co-authored-by: Chayim I. Kirshen <c@kirshen.com> Co-authored-by: dvora-h <dvora.heller@redis.com>