summaryrefslogtreecommitdiff
path: root/redis
Commit message (Collapse)AuthorAgeFilesLines
* Add optional exception handler to PubSubWorkerThread (#1395)Abhimanyu Deora2020-10-261-5/+18
| | | | | Add optional exception handler to PubSubWorkerThread Co-authored-by: Abhimanyu Deora <adeora@drwholdings.com>
* 🕰️ Use monotonic clock in Lock (and tests)Jack Edge2020-10-121-2/+2
| | | | | | | | | | | | | | | | | During a call to `acquire()`, if the call is `blocking` and has a `blocking_timeout` set, it uses `time.time()` calls to determine when to give up attempting to acquire the lock. However, since `time.time()` is marked as "adjustable", it is possible for it to go backwards or forwards at a rate other than 1 second per second, meaning the spinloop may exit earlier or later than expected. By changing the implementation to use `time.monotonic()`, which is guaranteed to never go backwards, and not be affected by system clock updates, this potential problem is fixed. For the same reason, some time dependent lock tests have also been changed to use `time.monotonic()`.
* Fixing #1390 modules key in info command (#1393)2014bduck2020-09-031-1/+7
| | | | | When modules are present, INFO's response will contain a `modules` key which will be a list of dicts describing each module. Co-authored-by: jiekun.zhu <jiekun.zhu@shopee.com>
* Added the ACL LOG command available in Redis 6Andy McCurdy2020-08-191-0/+61
| | | | | | | | | `acl_log()` returns a list of dictionaries, each describing a log entry. `acl_log_reset()` instructs the server to truncate the log. Thanks @2014BDuck Fixes #1307
* fix: Align from_url in utils.py to remove DB as a 2nd paramTom King2020-08-171-2/+2
|
* All values within Redis URLs are url-unquoted via default.Andy McCurdy2020-08-152-123/+105
| | | | | | | | Prior versions of redis-py supported this by specifying the ``decode_components`` flag to the ``from_url`` functions. This is now done by default and cannot be disabled. Fixes #589
* Remove support for end-of-life Python 2.7 (#1318)Jon Dufresne2020-08-066-514/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove support for end-of-life Python 2.7 Python 2.7 is end of life. It is no longer receiving bug fixes, including for security issues. Python 2.7 went EOL on 2020-01-01. For additional details on support Python versions, see: Supported: https://devguide.python.org/#status-of-python-branches EOL: https://devguide.python.org/devcycle/#end-of-life-branches Removing support for EOL Pythons will reduce testing and maintenance resources while allowing the library to move towards a modern Python 3 style. Python 2.7 users can continue to use the previous version of redis-py. Was able to simplify the code: - Removed redis._compat module - Removed __future__ imports - Removed object from class definition (all classes are new style) - Removed long (Python 3 unified numeric types) - Removed deprecated __nonzero__ method - Use simpler Python 3 super() syntax - Use unified OSError exception - Use yield from syntax Co-authored-by: Andy McCurdy <andy@andymccurdy.com>
* Fix some documentation formattingJon Banafato2020-07-262-29/+32
| | | | | Fix a few broken links and class references, move a docstring, and fix a code block.
* LPOS: add new command (#1354)Paul Spooren2020-07-221-0/+36
| | | | | Added the LPOS command from Redis 6.0.6 Fixes #1353
* fix typo (#1367)Roey Prat2020-07-131-1/+1
|
* Support for loading, unloading and listing Redis Modules (#1360)Roey Prat2020-07-133-0/+50
| | | | | | | | | | | * Support for loading, unloading and listing Redis Modules * minor fixes for flake * unit test for module list - only the empty use case * ModuleError should inherit from ResponseError rather than RedisError Co-authored-by: Vamsi Atluri <vamc19@gmail.com>
* Fix acl_setuser docstringAndrew Brookins2020-06-291-1/+1
| | | Fix the docstring for acl_setuser() so that it refers to the correct parameter name,`passwords`.
* Do not un-escape \ characters when parsing MONITOR outputAndy McCurdy2020-06-081-1/+4
| | | | | | | Prior to this, escaped slashes ("\\") were un-escaped. This caused the strings "foo\x92" and "foo\\x92" to be represented the same way in the output. Fixes #1349
* 3.5.33.5.3Andy McCurdy2020-06-011-1/+1
|
* SentinelConnectionPool plays better with threaded applications.Andy McCurdy2020-06-012-14/+51
| | | | | | | | | Prevent the pool from closing sockets on connections that are actively in use by other threads when the master address changes. Connections returned to the pool that are still connected to the old master will be disconnected gracefully. Fixes #1345
* [sentinel] update master address if it changes. (#847)Jake2020-05-201-0/+1
| | | Update the cached master_address if the Sentinels promote a new master.
* Restore try/except in __del__ methodsAndy McCurdy2020-05-202-8/+23
| | | | Fixed #1339
* 3.5.23.5.2Andy McCurdy2020-05-141-1/+1
|
* Tune the locking in ConnectionPool.get_connectionAndy McCurdy2020-05-141-21/+22
| | | | | The lock does not need to be held while waiting for the socket to establish and validate the TCP connection.
* 3.5.13.5.1Andy McCurdy2020-05-091-1/+1
|
* Fix for HSET argument validation to allow any non-None keyAleksMat2020-05-091-4/+4
| | | | | Fixes #1337 Fixes #1341
* version 3.5.03.5.0Andy McCurdy2020-04-291-1/+1
|
* Fix typo (missing space) in exception message (#1334)Jon Dufresne2020-04-281-1/+1
|
* Switch to flake8 for static code analysis (#1328)Jon Dufresne2020-04-164-3/+2
| | | | | | | | | flake8 catches a wider net of mistakes than pycodestyle and is more commonly used by the larger community. For example, it catches unused imports, a few of which existed. These have since been removed. Two "noqa" comments were added. One ignores the _compat.py file as it has a large amount of Python version specific code. The second is in utils.py which intentionally does not use an import.
* Enable BytesWarning during test and fix discovered case (#1322)Jon Dufresne2020-04-131-1/+5
| | | | | | | | | | | | The Python command line argument -b causes Python to emit a warning when bytes and str usage is mixed. This is generally considered bad practice as either one or the other is required. Enabling this feature during tests helps catch them before reaching production. The warning appeared as: tests/test_scripting.py::TestScripting::test_eval_msgpack_pipeline_error_in_lua .../redis-py/redis/client.py:3967: BytesWarning: str() on a bytes instance cmd = ' '.join(imap(safe_unicode, command))
* Fix str/bytes mixup in PythonParser.read_response() (#1324)Jon Dufresne2020-04-132-18/+11
| | | | | | | | | | | | Calling str() on a bytes object can result in a BytesWarning being emitted and usually indicates a mixup between byte and string handling. Now, in the event of an invalid RESP response, use the repr value of the raw response in the exception message. Can further simplify the bytes/str handling by comparing the first byte as a bytes object instead of converting it to str. The bytes literal is available on all supported Pythons. This removes the need for the compatibility function, byte_to_chr().
* Prefer Python 3 syntax in examples (#1325)Jon Dufresne2020-04-131-1/+1
| | | | As Python 3 is the future of the language, when the docs need to make a syntax choice, use the Python 3 version.
* Simplify exception handlers (#1319)Jon Dufresne2020-04-112-19/+15
| | | | | | | | | Use the "as" keyword to capture the exception in a variable instead of sys.exc_info(). Re-raise exception with the bare "raise" syntax. Avoid "# noqa: E722" by catching BaseException, which includes all exceptions including SystemExit.
* Fix typo: occured → occurred (#1315)Jon Dufresne2020-04-091-4/+4
|
* Lock.extend() can now replace the lock's existing TTL with a new valuelaixintao2020-03-241-14/+34
| | | | | | | Lock.extend() now has a new option, `replace_ttl`. When False (the default), Lock.extend() adds the `additional_time` to the lock's existing TTL. When replace_ttl=True, the lock's existing TTL is replaced with the value of `additional_time`.
* add keepttl option to set command.laixintao2020-03-121-1/+9
| | | | | fixes #1304 fixes #1280
* Clear pipeline watch state after execNick Gaya2020-03-101-0/+3
|
* Don't send DISCARD after ExecAbortError in pipelineNick Gaya2020-03-101-2/+0
| | | | | | | The `EXECABORT` error type was added in Redis 2.6.5 and is returned from an `EXEC` command to indicate that the transaction was aborted due to an invalid command. It is not necessary to call `DISCARD` after this error, and doing so causes a "DISCARD without MULTI" error.
* add support for the MEMORY STATS commandAndy McCurdy2020-02-251-3/+31
| | | | Fixes #1268
* Support memoryview encoding/decoding as a no-opCody-G2020-02-241-10/+15
| | | | | | | | | | This allows memoryview instances to be passed to Redis command args that expect strings or bytes. The memoryview instance is sent directly to the socket such that there are zero copies made of the underlying data during command packing. Fixes #1265 Fixes #1285
* Optimize sleeping while blocking for a lockColas Le Guernic2020-02-241-3/+2
| | | | | | | | | When waiting to acquire a lock, the Lock object will sleep until the lock is acquired or until blocking_timeout has elapsed. This optimization calculates whether the next iteration will occur after blocking_timeout has elapsed and short circuits it immediately. Fixes #1263
* expand AUTH fallback support to pre-v6 Redis servers.Andy McCurdy2020-02-121-0/+6
| | | | Ref #1274
* Stop hiding errors that occur inside __del__ methodsJon Dufresne2020-02-122-23/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If an exception occurs inside the __del__ method, it should be reported to the developer. Not doing so could hide bugs. Python automatically handles exceptions inside __del__ methods, for example: class A: def __del__(self): 1 / 0 A() print("after del") Results in the output: $ python3 ~/blah.py Exception ignored in: <function A.__del__ at 0x7fbbf2bbfc20> Traceback (most recent call last): File "/home/jon/test.py", line 3, in __del__ 1 / 0 ZeroDivisionError: division by zero after del From this example, we can see the bug was not hidden and the code after __del__ still executed. fixes #1281
* Drop unused variables and imports (#1284)Jon Dufresne2020-02-121-1/+1
|
* Improve Redis.hmset() warning messageJon Dufresne2020-02-121-1/+6
| | | | | | | | | It now describe what is deprecated and displays for the callers line by using stacklevel=2. The warning is now tested and not emitted during normal test runs. Fixes #1282
* Make hset support multiple field/value pairs. (#1271)赖信涛2020-02-071-4/+16
| | | | | | | | | | | | * make `hset` command support multi field/value pairs. see: https://redis.io/commands/hset close https://github.com/andymccurdy/redis-py/issues/1269 deprecated: hmset Co-authored-by: Alan Mai <0110amai@gmail.com>
* 3.4.13.4.1Andy McCurdy2020-02-011-1/+1
|
* remove Redis and ConnectionPool __eq__ comparisonAndy McCurdy2020-02-012-12/+0
| | | | | | | | | | | | | After further thought this was a bad idea. Just because two connection pools share the same connection arguments does not make them equal. It would seem quite odd if pool_a == pool_b yet pool_a.disconnect() doesn't close all of pool_b's connections. Ref #1240 Fixes #1277 Fixes #1275 Fixes #1267 Fixes #1273
* Move the username argument in the Redis and Connection classes to the endAndy McCurdy2020-01-312-8/+7
| | | | | | | This helps those poor souls that specify all their connection options as non-keyword arguments. Fixes #1276
* Provide AUTH fallback support for connection URLs with a username componentAndy McCurdy2020-01-313-1/+25
| | | | | | | | | | | | | Prior to ACL support, redis-py ignored the username component of Connection URLs. With ACL support, usernames are no longer ignored and are used to authenticate against an ACL rule. Some cloud vendors with managed Redis instances (like Heroku) provide connection URLs with a username component pre-ACL that is not intended to be used. Sending that username to Redis servers < 6.0.0 results in an error. Attempt to detect this condition and retry the AUTH command with only the password such that authentication continues to work for these users. Fixes #1274
* 3.4.03.4.0Andy McCurdy2020-01-301-1/+1
|
* better thread-safety for ConnectionPool (#1270)Andy McCurdy2020-01-303-48/+146
| | | Better thread and fork safety for ConnectionPool and BlockingConnectionPool
* Fix spelling in docstring (#1272)Damon Jablons2020-01-301-1/+1
|
* add type filter to scan functionnetocp2020-01-301-5/+20
| | | | Fixed #1220
* Slight optimization to command packing.Andy McCurdy2019-12-291-3/+4
| | | | Fixed #1255