summaryrefslogtreecommitdiff
path: root/redis/connection.py
Commit message (Collapse)AuthorAgeFilesLines
* Optionally disable disconnects in read_response (#2695)Kristján Valur Jónsson2023-05-081-6/+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
* Fix potential race condition during disconnection (#2719)Markus Gerstel2023-05-011-4/+6
| | | | | | | | | | | | | | | When the disconnect() function is called twice in parallel it is possible that one thread deletes the self._sock reference, while the other thread will attempt to call .close() on it, leading to an AttributeError. This situation can routinely be encountered by closing the connection in a PubSubWorkerThread error handler in a blocking thread (ie. with sleep_time==None), and then calling .close() on the PubSub object. The main thread will then run into the disconnect() function, and the listener thread is woken up by the closure and will race into the disconnect() function, too. This can be fixed easily by copying the object reference before doing the None-check, similar to what we do in the redis.client.close() function.
* asyncio: Fix memory leak caused by hiredis (#2693) (#2694)Oran Avraham2023-04-131-3/+4
|
* UnixDomainSocketConnection missing constructor argument (#2630)woutdenolf2023-03-281-1/+2
|
* introduce AbstractConnection so that UnixDomainSocketConnection can call ↵woutdenolf2023-03-161-158/+120
| | | | | super().__init__ (#2588) Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Speeding up the protocol parsing (#2596)Chayim2023-03-151-13/+11
| | | | | | | * speeding up the protocol parser * linting * changes to ease
* Fix #2581 UnixDomainSocketConnection' object has no attribute ↵Sergey Prokazov2023-02-081-0/+2
| | | | | | | | | | | | | | | | | '_command_packer' (#2583) * Fix #2581 UnixDomainSocketConnection' object has no attribute '_command_packer' . Apparently there is no end-to-end tests for Unix sockets so automation didn't catch it. I assume that setting up domain sockets reliably in dockerized environment is not very trivial. Added test for pack_command specifically. * Figuring out why CI fails. Locally: " congratulations :)" * Fix the test. hiredis doesn't treat memoryviews differently.
* 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 2567: NoneType check before raising exception (#2569)Anurag Bandyopadhyay2023-02-061-2/+3
| | | Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
* Use hiredis::pack_command to serialized the commands. (#2570)Sergey Prokazov2023-02-061-45/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implemented pack command and pack bytes * 1) refactored the command packer construction process 2) now hiredis.pack_bytes is the default choice. Though it's still possible to run redisrs-py (fix the flag in utils.py) or hiredis.pack_command (flag in connection.py) * Switch to hiredis.pack_command * Remove the rust extension module. * 1) Introduce HIREDIS_PACK_AVAILABLE environment variable. 2) Extract serialization functionality out of Connection class. * 1) Fix typo. 2) Add change log entry. 3) Revert the benchmark changes * Ditch the hiredis version check for pack_command. * Fix linter errors * Revert version changes * Fix linter issues * Looks like the current redis-py version is 4.4.1 --------- Co-authored-by: Sergey Prokazov <sergey.prokazov@redis.com>
* Simplify the sync SocketBuffer, add type hints (#2543)Kristján Valur Jónsson2023-01-221-39/+44
|
* Make PythonParser resumable (#2510)Kristján Valur Jónsson2023-01-051-16/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Fix for Unhandled exception related to self.host with unix socket (#2520)Jason Joy Atsu Winmorre2022-12-251-11/+23
| | | | | | | | | * Fix for Unhandled exception related to self.host with unix socket * Added change to the CHANGES file * fix linter error * Reformatted connection.py file
* Combine auto-concatenated strings (#2482)David Gilman2022-12-141-2/+2
|
* Failover handling improvements for RedisCluster and Async RedisCluster (#2377)Bar Shaul2022-11-101-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-9/+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>
* Catch `Exception` and not `BaseException` in the `Connection` (#2104)Kristján Valur Jónsson2022-09-291-2/+2
| | | | | | | * Add failing unittests for passing BaseException through * Resolve failing unittest * Remove redundant checks for asyncio.CancelledError
* Support Hiredis >= 1.x only (remove `packaging` dependency) (#2385)Aarni Koskela2022-09-281-44/+10
| | | | | | | * Only set HIREDIS_AVAILABLE if Hiredis is not 0.x * Remove compatibility code for old Hiredis versions * Move packaging dependency to dev only
* Handle auth errors for newer versions of Redis. (#2325) (#2329)Luca Cillario2022-08-301-1/+11
|
* Be more strict about url scheme parsing (#2343)Klaas van Schelven2022-08-211-6/+11
| | | | | | | | | | The error message implied that urls had to start with `scheme://`. However, if the double slash was left out, the url parsed just fine and the part that was ostensibly intended to be the hostname ended up as part of the path, whereas the default (localhost) would be used for the hostname. This commit makes the check as strict as the error message implies by including a check for the double slash. Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
* Fix retries in async mode (#2180)Eric Lemoine2022-06-191-2/+6
| | | | | | | | | * 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-14/+5
|
* 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
* Rename 'update_supported_erros' to 'update_supported_errors' in Retry module ↵Jean Lopin2022-05-021-2/+2
| | | | (#2144)
* 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
* Catch OSError in BlockingConnectionPool.get_connection (#2001)Éric Lemoine2022-02-221-1/+1
| | | Co-authored-by: Chayim I. Kirshen <c@kirshen.com>
* Add support for Redis 7 functions (#1998)dvora-h2022-02-221-2/+9
| | | | | | | | | | | | | | | | | | | * add function support * linters * test fcall * decode reponses for unstable_r * linters * fix evalsho_ro test * fix eval_ro test * add response callbaks * linters
* Fixing AttributeError on some connection errors (#1905)Chayim2022-01-261-4/+7
|
* Fixing AttributeError in UnixDomainSocketConnection (#1903)dvora-h2022-01-261-5/+12
|
* Added retry mechanism on socket timeouts when connecting to the server (#1895)Bar Shaul2022-01-251-2/+4
|
* OCSP Stapling Support (#1873)Chayim2022-01-171-1/+47
|
* get_connection: catch OSError too (#1832)Iñaki Ucar2022-01-101-1/+1
|
* Documentation cleanup (#1841)Chayim2021-12-301-2/+3
|
* OCSP stapling support (#1820)Chayim2021-12-261-2/+15
|
* Support for specifying error types with retry (#1817)Bar Shaul2021-12-231-4/+23
|
* Support for password-encrypted SSL private keys (#1782)Chayim2021-12-161-4/+31
| | | Adding support for SSL private keys with a password. This PR also adds support for future SSL tests.
* close socket after server disconnect (#1797)Paul Brown2021-12-161-2/+7
|
* Support SYNC and PSYNC (#1741)Avital Fine2021-12-151-1/+1
| | | Co-authored-by: Chayim <chayim@users.noreply.github.com>
* Ensure redis_connect_func is set on uds connection (#1794)Ali-Akber Saifee2021-12-151-1/+3
|
* Allow overriding connection class via keyword arguments (#1752)Maksim Novikov2021-12-021-0/+4
|
* Added black and isort (#1734)Anas2021-11-301-185/+244
|
* Pyupgrade + flynt + f-strings (#1759)Aarni Koskela2021-11-301-34/+31
| | | @akx Thank you so much for this! Thanks again for introducing me to a new tool that I'm sliding into my workflow as well.
* Fixing deprecating distutils (PEP 632) (#1730)Chayim2021-11-251-5/+5
|
* Adding support for non-decodable commands (#1731)Chayim2021-11-251-6/+9
|
* Adding RedisCluster client to support Redis Cluster Mode (#1660)Bar Shaul2021-11-251-6/+23
| | | | Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: Anas <anas.el.amraoui@live.com>
* Better removal of hiredis warning (#1726)Alex Wu2021-11-211-4/+0
| | | Co-authored-by: Alex Wu <alex@anyscale.com>
* removing hiredis warning (#1721)Chayim2021-11-171-5/+0
|
* Fix garbage collection deadlock (#1578)Eugene Morozov2021-11-081-3/+6
|
* Adding vulture for static analysis (#1655)Chayim2021-10-281-1/+0
| | | | | * Adding vulture for static analysis Removing dead code found previously by vulture in local runs.