Skip to content

Commit c34e8e8

Browse files
authored
Merge branch 'master' into v5-client-subcommands
2 parents 9a5d994 + 5f61ad9 commit c34e8e8

33 files changed

+1125
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ vagrant/.vagrant
99
.python-version
1010
.cache
1111
.eggs
12+
.idea

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ python:
77
- "3.3"
88
- "2.7"
99
- "2.6"
10-
services:
11-
- redis-server
10+
before_install:
11+
- wget http://download.redis.io/releases/redis-5.0.0.tar.gz && mkdir redis_install && tar -xvzf redis-5.0.0.tar.gz -C redis_install && cd redis_install/redis-5.0.0 && make && src/redis-server --daemonize yes && cd ../..
12+
- redis-cli info
1213
env:
1314
- TEST_HIREDIS=0
1415
- TEST_HIREDIS=1
1516
install:
1617
- pip install -e .
17-
- "if [[ $TEST_PEP8 == '1' ]]; then pip install pep8; fi"
18+
- "if [[ $TEST_PYCODESTYLE == '1' ]]; then pip install pycodestyle; fi"
1819
- "if [[ $TEST_HIREDIS == '1' ]]; then pip install hiredis; fi"
19-
script: "if [[ $TEST_PEP8 == '1' ]]; then pep8 --repeat --show-source --exclude=.venv,.tox,dist,docs,build,*.egg .; else python setup.py test; fi"
20+
script: "if [[ $TEST_PYCODESTYLE == '1' ]]; then pycodestyle --repeat --show-source --exclude=.venv,.tox,dist,docs,build,*.egg,redis_install .; else python setup.py test; fi"
2021
matrix:
2122
include:
2223
- python: "2.7"
23-
env: TEST_PEP8=1
24+
env: TEST_PYCODESTYLE=1
2425
- python: "3.6"
25-
env: TEST_PEP8=1
26+
env: TEST_PYCODESTYLE=1

CHANGES

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* 2.10.6
22
* Various performance improvements. Thanks cjsimpson
3-
* Fixed a bug with SRANDMEMBER where
3+
* Fixed a bug with SRANDMEMBER where the behavior for `number=0` did
4+
not match the spec. Thanks Alex Wang
45
* Added HSTRLEN command. Thanks Alexander Putilin
56
* Added the TOUCH command. Thanks Anis Jonischkeit
67
* Remove unnecessary calls to the server when registering Lua scripts.
@@ -190,7 +191,7 @@
190191
for the report.
191192
* Connections now call socket.shutdown() prior to socket.close() to
192193
ensure communication ends immediately per the note at
193-
http://docs.python.org/2/library/socket.html#socket.socket.close
194+
https://docs.python.org/2/library/socket.html#socket.socket.close
194195
Thanks to David Martin for pointing this out.
195196
* Lock checks are now based on floats rather than ints. Thanks
196197
Vitja Makarov.
@@ -224,11 +225,11 @@
224225
* Prevent DISCARD from being called if MULTI wasn't also called. Thanks
225226
Pete Aykroyd.
226227
* SREM now returns an integer indicating the number of items removed from
227-
the set. Thanks http://github.com/ronniekk.
228+
the set. Thanks https://github.com/ronniekk.
228229
* Fixed a bug with BGSAVE and BGREWRITEAOF response callbacks with Python3.
229230
Thanks Nathan Wan.
230231
* Added CLIENT GETNAME and CLIENT SETNAME commands.
231-
Thanks http://github.com/bitterb.
232+
Thanks https://github.com/bitterb.
232233
* It's now possible to use len() on a pipeline instance to determine the
233234
number of commands that will be executed. Thanks Jon Parise.
234235
* Fixed a bug in INFO's parse routine with floating point numbers. Thanks

README.rst

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ redis-py
44
The Python interface to the Redis key-value store.
55

66
.. image:: https://secure.travis-ci.org/andymccurdy/redis-py.png?branch=master
7-
:target: http://travis-ci.org/andymccurdy/redis-py
7+
:target: https://travis-ci.org/andymccurdy/redis-py
88
.. image:: https://readthedocs.org/projects/redis-py/badge/?version=latest&style=flat
99
:target: https://redis-py.readthedocs.io/en/latest/
1010
.. image:: https://badge.fury.io/py/redis.svg
@@ -14,20 +14,14 @@ Installation
1414
------------
1515

1616
redis-py requires a running Redis server. See `Redis's quickstart
17-
<http://redis.io/topics/quickstart>`_ for installation instructions.
17+
<https://redis.io/topics/quickstart>`_ for installation instructions.
1818

1919
To install redis-py, simply:
2020

2121
.. code-block:: bash
2222
2323
$ sudo pip install redis
2424
25-
or alternatively (you really should be using pip though):
26-
27-
.. code-block:: bash
28-
29-
$ sudo easy_install redis
30-
3125
or from source:
3226

3327
.. code-block:: bash
@@ -59,7 +53,7 @@ specified.
5953
API Reference
6054
-------------
6155

62-
The `official Redis command documentation <http://redis.io/commands>`_ does a
56+
The `official Redis command documentation <https://redis.io/commands>`_ does a
6357
great job of explaining each command in detail. redis-py exposes two client
6458
classes that implement these commands. The StrictRedis class attempts to adhere
6559
to the official command syntax. There are a few exceptions:
@@ -162,19 +156,12 @@ kind enough to create Python bindings. Using Hiredis can provide up to a
162156
performance increase is most noticeable when retrieving many pieces of data,
163157
such as from LRANGE or SMEMBERS operations.
164158

165-
Hiredis is available on PyPI, and can be installed via pip or easy_install
166-
just like redis-py.
159+
Hiredis is available on PyPI, and can be installed via pip just like redis-py.
167160

168161
.. code-block:: bash
169162
170163
$ pip install hiredis
171164
172-
or
173-
174-
.. code-block:: bash
175-
176-
$ easy_install hiredis
177-
178165
Response Callbacks
179166
^^^^^^^^^^^^^^^^^^
180167

@@ -276,7 +263,7 @@ could do something like this:
276263
.. code-block:: pycon
277264
278265
>>> with r.pipeline() as pipe:
279-
... while 1:
266+
... while True:
280267
... try:
281268
... # put a WATCH on the key that holds our sequence value
282269
... pipe.watch('OUR-SEQUENCE-KEY')
@@ -309,7 +296,7 @@ explicitly calling reset():
309296
.. code-block:: pycon
310297
311298
>>> pipe = r.pipeline()
312-
>>> while 1:
299+
>>> while True:
313300
... try:
314301
... pipe.watch('OUR-SEQUENCE-KEY')
315302
... ...
@@ -626,7 +613,7 @@ execution.
626613
Sentinel support
627614
^^^^^^^^^^^^^^^^
628615

629-
redis-py can be used together with `Redis Sentinel <http://redis.io/topics/sentinel>`_
616+
redis-py can be used together with `Redis Sentinel <https://redis.io/topics/sentinel>`_
630617
to discover Redis nodes. You need to have at least one Sentinel daemon running
631618
in order to use redis-py's Sentinel support.
632619

@@ -667,7 +654,7 @@ If no slaves can be connected to, a connection will be established with the
667654
master.
668655

669656
See `Guidelines for Redis clients with support for Redis Sentinel
670-
<http://redis.io/topics/sentinel-clients>`_ to learn more about Redis Sentinel.
657+
<https://redis.io/topics/sentinel-clients>`_ to learn more about Redis Sentinel.
671658

672659
Scan Iterators
673660
^^^^^^^^^^^^^^
@@ -691,7 +678,7 @@ Author
691678
^^^^^^
692679

693680
redis-py is developed and maintained by Andy McCurdy ([email protected]).
694-
It can be found here: http://github.com/andymccurdy/redis-py
681+
It can be found here: https://github.com/andymccurdy/redis-py
695682

696683
Special thanks to:
697684

benchmarks/basic_operations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,6 @@ def hmset(conn, num, pipeline_size, data_size):
195195
if pipeline_size > 1:
196196
conn.execute()
197197

198+
198199
if __name__ == '__main__':
199200
run()

benchmarks/command_packer_benchmark.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def send_packed_command(self, command):
2222
_errno, errmsg = e.args
2323
raise ConnectionError("Error %s while writing to socket. %s." %
2424
(_errno, errmsg))
25-
except:
25+
except Exception as e:
2626
self.disconnect()
27-
raise
27+
raise e
2828

2929
def pack_command(self, *args):
3030
"Pack a series of arguments into a value Redis command"
@@ -54,9 +54,9 @@ def send_packed_command(self, command):
5454
_errno, errmsg = e.args
5555
raise ConnectionError("Error %s while writing to socket. %s." %
5656
(_errno, errmsg))
57-
except:
57+
except Exception as e:
5858
self.disconnect()
59-
raise
59+
raise e
6060

6161
def pack_command(self, *args):
6262
output = []

build_tools/.bash_profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PATH=$PATH:/var/lib/redis/bin
File renamed without changes.

vagrant/build_redis.sh renamed to build_tools/build_redis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
source /home/vagrant/redis-py/vagrant/redis_vars.sh
3+
source /home/vagrant/redis-py/build_tools/redis_vars.sh
44

55
pushd /home/vagrant
66

vagrant/install_redis.sh renamed to build_tools/install_redis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
source /home/vagrant/redis-py/vagrant/redis_vars.sh
3+
source /home/vagrant/redis-py/build_tools/redis_vars.sh
44

55
for filename in `ls $VAGRANT_REDIS_CONF_DIR`; do
66
# cuts the order prefix off of the filename, e.g. 001-master -> master

vagrant/install_sentinel.sh renamed to build_tools/install_sentinel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
source /home/vagrant/redis-py/vagrant/redis_vars.sh
3+
source /home/vagrant/redis-py/build_tools/redis_vars.sh
44

55
for filename in `ls $VAGRANT_SENTINEL_CONF_DIR`; do
66
# cuts the order prefix off of the filename, e.g. 001-master -> master

vagrant/redis-configs/001-master renamed to build_tools/redis-configs/001-master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ daemonize yes
55
unixsocket /tmp/redis_master.sock
66
unixsocketperm 777
77
dbfilename master.rdb
8-
dir /home/vagrant/redis/backups
8+
dir /var/lib/redis/backups

vagrant/redis-configs/002-slave renamed to build_tools/redis-configs/002-slave

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ daemonize yes
55
unixsocket /tmp/redis-slave.sock
66
unixsocketperm 777
77
dbfilename slave.rdb
8-
dir /home/vagrant/redis/backups
8+
dir /var/lib/redis/backups
99

1010
slaveof 127.0.0.1 6379

vagrant/redis_init_script renamed to build_tools/redis_init_script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
REDISPORT={{ PORT }}
1414
PIDFILE=/var/run/{{ PROCESS_NAME }}.pid
15-
CONF=/home/vagrant/redis/conf/{{ PROCESS_NAME }}.conf
15+
CONF=/var/lib/redis/conf/{{ PROCESS_NAME }}.conf
1616

17-
EXEC=/home/vagrant/redis/bin/redis-server
18-
CLIEXEC=/home/vagrant/redis/bin/redis-cli
17+
EXEC=/var/lib/redis/bin/redis-server
18+
CLIEXEC=/var/lib/redis/bin/redis-cli
1919

2020
case "$1" in
2121
start)

vagrant/redis_vars.sh renamed to build_tools/redis_vars.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

3-
VAGRANT_DIR=/home/vagrant/redis-py/vagrant
3+
VAGRANT_DIR=/home/vagrant/redis-py/build_tools
44
VAGRANT_REDIS_CONF_DIR=$VAGRANT_DIR/redis-configs
55
VAGRANT_SENTINEL_CONF_DIR=$VAGRANT_DIR/sentinel-configs
66
REDIS_VERSION=3.2.0
77
REDIS_DOWNLOAD_DIR=/home/vagrant/redis-downloads
88
REDIS_PACKAGE=redis-$REDIS_VERSION.tar.gz
99
REDIS_BUILD_DIR=$REDIS_DOWNLOAD_DIR/redis-$REDIS_VERSION
10-
REDIS_DIR=/home/vagrant/redis
10+
REDIS_DIR=/var/lib/redis
1111
REDIS_BIN_DIR=$REDIS_DIR/bin
1212
REDIS_CONF_DIR=$REDIS_DIR/conf
1313
REDIS_SAVE_DIR=$REDIS_DIR/backups
File renamed without changes.
File renamed without changes.
File renamed without changes.

vagrant/sentinel_init_script renamed to build_tools/sentinel_init_script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
SENTINELPORT={{ PORT }}
1414
PIDFILE=/var/run/{{ PROCESS_NAME }}.pid
15-
CONF=/home/vagrant/redis/conf/{{ PROCESS_NAME }}.conf
15+
CONF=/var/lib/redis/conf/{{ PROCESS_NAME }}.conf
1616

17-
EXEC=/home/vagrant/redis/bin/redis-sentinel
18-
CLIEXEC=/home/vagrant/redis/bin/redis-cli
17+
EXEC=/var/lib/redis/bin/redis-sentinel
18+
CLIEXEC=/var/lib/redis/bin/redis-cli
1919

2020
case "$1" in
2121
start)

redis/_compat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
try:
66
InterruptedError = InterruptedError
7-
except:
7+
except NameError:
88
InterruptedError = OSError
99

1010
# For Python older than 3.5, retry EINTR.
@@ -13,7 +13,6 @@
1313
# Adapted from https://bugs.python.org/review/23863/patch/14532/54418
1414
import socket
1515
import time
16-
import errno
1716

1817
from select import select as _select
1918

0 commit comments

Comments
 (0)