Git Product home page Git Product logo

redislite's Introduction

Redislite

CI/CD Build Status Codestyle Coverage Current Version Supported Python License Documentation

Description

Redislite is a self contained Python interface to the Redis key-value store.

It provides enhanced versions of the Redis-Py Python bindings for Redis. That provide the following added functionality:

  • Easy to use - It provides a built in Redis server that is automatically installed, configured and managed when the Redis bindings are used.
  • Flexible - Create a single server shared by multiple programs or multiple independent servers. All the servers provided by Redislite support all Redis functionality including advanced features such as replication and clustering.
  • Compatible - It provides enhanced versions of the Redis-Py python Redis bindings as well as functions to patch them to allow most existing code that uses them to run with little or no modifications.
  • Secure - It uses a secure default Redis configuraton that is only accessible by the creating user on the computer system it is run on.

Requirements

The redislite module requires Python 3.6 or higher.

Installing requirements on Linux

Make sure Python development headers are available when installing redislite.

On Ubuntu/Debian systems, install them with:

apt-get install python-dev

On Redhat/Fedora systems, install them with:

yum install python-devel

Installing requirements on Mac OSX

Redislite for OSX comes as a wheel package by default that can be installed using current versions of pip.

To install Redislite on MacOSX using the sdist package instead you will need the XCode command line utilities installed. If you do not have xcode installed on recent OSX releases they can be installed by running:

xcode-select --install

Installing requirements on Microsoft Windows

Redislite can be installed on newer releases of Windows 10 under the Bash on Ubuntu shell.

Install it using the instructions at https://msdn.microsoft.com/commandline/wsl/install_guide

Then start the bash shell and install the python-dev package as follows:

apt-get install python-dev

Installation

To install redislite, simply:

$ pip install redislite

or from source:

$ python setup.py install

Getting Started

redislite provides enhanced versions of the redis-py redis.Redis() and redis.StrictRedis() classes that take the same arguments as the corresponding redis classes and take one additional optional argument. Which is the name of the Redis rdb file to use. If the argument is not provided it will create set up a new redis server.

redislite also provides functions to MonkeyPatch the redis.Redis and redis.StrictRedis classes to use redislite, so existing python code that uses Redis can use the redislite version.

Examples

Here are some examples of using the redislite module.

Setting a value

Here we open a Python shell and set a key in our embedded Redis db. Redislite will automatically start the Redis server when the Redis() object is created and shut it down cleanly when the Python interpreter exits.

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
[]
>>> redis_connection.set('key', 'value')
True
>>> redis_connection.get('key')
'value'

Persistence

Now we open the same Redis db and access the key we created during the last run. Redislite will automatically start the Redis server using the same configuration as last time, so the value that was set in the previous example is still available.

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
['key']
>>> redis_connection.get('key')
'value'

Compatibility

It's possible to MonkeyPatch the normal Redis classes to allow modules that use Redis to use the redislite classes. Here we patch Redis and use the redis_collections module.

>>> import redislite.patch
>>> redislite.patch.patch_redis()
>>> import redis_collections
>>> td = redis_collections.Dict()
>>> td['foo']='bar'
>>> td.keys()
['foo']

Running and using Multiple servers

Redislite will start a new server if the redis rdb fileame isn't specified or is new. In this example we start 10 seperate redis servers and set the value of the key 'servernumber' to a different value in each server.

Then we access the value of 'servernumber' and print it.

>>> import redislite
>>> servers = {}
>>> for redis_server_number in range(10):
...     servers[redis_server_number] = redislite.Redis()
...     servers[redis_server_number].set('servernumber', redis_server_number)
...
True
True
True
True
True
True
True
True
True
True
>>> for redis_server in servers.values():
...     redis_server.get('servernumber')
...
b'0'
b'1'
b'2'
b'3'
b'4'
b'5'
b'6'
b'7'
b'8'
b'9'

Multiple Servers with different configurations in the same script

It's possible to spin up multiple instances with different configuration settings for the Redis server. Here is an example that sets up 2 redis server instances. One instance is configured to listen on port 8002, the second instance is a read-only slave of the first instance.

>>> import redislite
>>> master=redislite.Redis(serverconfig={'port': '8002'})
>>> slave=redislite.Redis(serverconfig={'slaveof': "127.0.0.1 8002"})
>>> slave.keys()
[]
>>> master.set('key', 'value')
True
>>> master.keys()
['key']
>>> slave.keys()
['key']
>>>

More Information

There is more detailed information on the redislite documentation page at http://redislite.readthedocs.org/en/latest/

Redislite is Free software under the New BSD license, see LICENSE.txt for details.

redislite's People

Contributors

anilkumarmyla avatar cailloumajor avatar dangayle avatar dwighthubbard avatar geonu avatar howardhaimovitch avatar jacobtolar avatar m1so avatar manuphatak avatar pztrick avatar retlawrose avatar slupers avatar sww avatar tvd0x2a avatar tzunieh avatar yashbathia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redislite's Issues

`pip install redislite` fails on m1 mac

Overview

pip install redislite fails on m1 mac

Environment

  • Python version 3.8.2
  • Pip version 21.2.4
  • gcc version 12.0.5 (apple arm)
% gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Steps to reproduce

Run pip install redislite on m1 mac native terminal (not using Rosetta 2). Note that installing with terminal using Rosetta (x86 compatibility mode) succeeds.

    gcc -std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -c debug.c
    debug.c:750:42: error: no member named '__eip' in 'struct __darwin_arm_thread_state64'
        return (void*) uc->uc_mcontext->__ss.__eip;
                       ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:844:47: error: no member named '__eax' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__eax,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:845:47: error: no member named '__ebx' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__ebx,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:846:47: error: no member named '__ecx' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__ecx,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:847:47: error: no member named '__edx' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__edx,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:848:47: error: no member named '__edi' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__edi,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:849:47: error: no member named '__esi' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__esi,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:850:47: error: no member named '__ebp' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__ebp,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:851:47: error: no member named '__esp' in 'struct __darwin_arm_thread_state64'; did you mean '__sp'?
            (unsigned long) uc->uc_mcontext->__ss.__esp,
                                                  ^~~~~
                                                  __sp
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:139:13: note: '__sp' declared here
            __uint64_t __sp;    /* Stack pointer x31 */
                       ^
    debug.c:852:47: error: no member named '__ss' in 'struct __darwin_arm_thread_state64'; did you mean '__sp'?
            (unsigned long) uc->uc_mcontext->__ss.__ss,
                                                  ^~~~
                                                  __sp
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:139:13: note: '__sp' declared here
            __uint64_t __sp;    /* Stack pointer x31 */
                       ^
    debug.c:853:47: error: no member named '__eflags' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__eflags,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:854:47: error: no member named '__eip' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__eip,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:855:47: error: no member named '__cs' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__cs,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:856:47: error: no member named '__ds' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__ds,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:857:47: error: no member named '__es' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__es,
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:858:47: error: no member named '__fs' in 'struct __darwin_arm_thread_state64'; did you mean '__fp'?
            (unsigned long) uc->uc_mcontext->__ss.__fs,
                                                  ^~~~
                                                  __fp
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:137:13: note: '__fp' declared here
            __uint64_t __fp;    /* Frame pointer x29 */
                       ^
    debug.c:859:47: error: no member named '__gs' in 'struct __darwin_arm_thread_state64'
            (unsigned long) uc->uc_mcontext->__ss.__gs
                            ~~~~~~~~~~~~~~~~~~~~~ ^
    debug.c:861:51: error: no member named '__esp' in 'struct __darwin_arm_thread_state64'; did you mean '__sp'?
        logStackContent((void**)uc->uc_mcontext->__ss.__esp);
                                                      ^~~~~
                                                      __sp
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:139:13: note: '__sp' declared here
            __uint64_t __sp;    /* Stack pointer x31 */
                       ^
    18 errors generated.
    make[1]: *** [debug.o] Error 1
    make: *** [install] Error 2
    ********************************************************************************
    creating build/scripts-3.8
    error: can't copy '/private/var/folders/ky/g05mfhfd4cg20s6tz1vzq4c00000gn/T/pip-install-9wzyr8yb/redislite_a8e4cb73fa444ddb8563f8864de2e505/redis.submodule/bin/redis-server': doesn't exist or not a regular file
    ----------------------------------------

Proposing a PR to fix a few small typos

Issue Type

[x] Bug (Typo)

Steps to Replicate and Expected Behaviour

  • Examine redis.submodule/src/networking.c and observe funciton, however expect to see function.
  • Examine redis.submodule/src/expire.c and observe wriatable, however expect to see writable.
  • Examine redis.submodule/src/redis-cli.c and observe varialbe, however expect to see variable.
  • Examine redis.submodule/src/ziplist.c and observe vacataed, however expect to see vacated.
  • Examine redis.submodule/src/replication.c and observe trasmit, however expect to see transmit.
  • Examine redis.submodule/src/replication.c and observe resynchorinization, however expect to see resynchronization.
  • Examine redis.submodule/src/lolwut5.c and observe representaiton, however expect to see representation.
  • Examine redis.submodule/src/rax.c and observe grestest, however expect to see greatest.
  • Examine redis.submodule/src/module.c and observe greter, however expect to see greater.
  • Examine redis.submodule/src/modules/helloworld.c and observe exaxctly, however expect to see exactly.
  • Examine redis.submodule/src/hyperloglog.c and observe elmenet, however expect to see element.
  • Examine redis.submodule/src/modules/hellodict.c and observe dictionray, however expect to see dictionary.
  • Examine redis.submodule/src/cluster.c and observe descritor, however expect to see descriptor.
  • Examine redis.submodule/src/sentinel.c and observe deliever, however expect to see deliver.
  • Examine redis.submodule/src/module.c and observe comparision, however expect to see comparison.

Notes

Semi-automated issue generated by
https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

To avoid wasting CI processing resources a branch with the fix has been
prepared but a pull request has not yet been created. A pull request fixing
the issue can be prepared from the link below, feel free to create it or
request @timgates42 create the PR. Alternatively if the fix is undesired please
close the issue with a small comment about the reasoning.

https://github.com/timgates42/redislite/pull/new/bugfix_typos

Thanks.

Race condition -> redis.exceptions.BusyLoadingError

If I have a DB with some items in it, sometimes it takes redis too long to load them, and redislite fails with:

Traceback (most recent call last):
  File "temp.py", line 17, in <module>
    db = redislite.StrictRedis('testdb.redis')
  File "/home/fxkr/.local/lib/python2.7/site-packages/redislite/client.py", line 338, in __init__
    self.ping()
  File "/usr/lib/python2.7/site-packages/redis/client.py", line 674, in ping
    return self.execute_command('PING')
  File "/usr/lib/python2.7/site-packages/redis/client.py", line 571, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/usr/lib/python2.7/site-packages/redis/client.py", line 577, in parse_response
    response = connection.read_response()
  File "/usr/lib/python2.7/site-packages/redis/connection.py", line 569, in read_response
    response = self._parser.read_response()
  File "/usr/lib/python2.7/site-packages/redis/connection.py", line 241, in read_response
    raise error
redis.exceptions.BusyLoadingError: Redis is loading the dataset in memory

To reproduce, generate a DB:

import redislite, os
db = redislite.StrictRedis('bug.redis')
for key in xrange(10000):
    db.hset("h1", os.urandom(32), " " * 65536)
db.save()

Then try to load it again. This will fail in most cases (on my machine):

db = redislite.StrictRedis('bug.redis')

Failure to install on Raspberry Pi 4

Installation via pip install redislite and python setup.py install (off a fresh clone from master) both fail with the following error while compiling Redis:

gcc   -g -ggdb -rdynamic -o redis-server adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a -lm -ldl -pthread -lrt              
/usr/bin/ld: networking.o: in function `createClient':                                                                              
 /tmp/pip-install-8wo6la69/redislite/redis.submodule/src/networking.c:109: undefined reference to `__atomic_fetch_add_8'              collect2: error: ld returned 1 exit status                                                                                          
 make[1]: *** [Makefile:219: redis-server] Error 1                                                                                   
 make[1]: Leaving directory '/tmp/pip-install-8wo6la69/redislite/redis.submodule/src'                                                
 make: *** [Makefile:9: install] Error 2

This appears to be redis/redis#6275 which was fixed by commit redis/redis@e9564dc

Simply adding to the LD_FLAGS in the redis Makefile appears to fix the issue, which I have verified myself and confirms that redislite does install and function with that change applied to the redis.submodule directory

db not saved to file

Redislite is not dumping to file for me:

>>> from redislite import Redis
>>> r = Redis('test.db')
>>> r.set('foo', 'bar')
>>> r.get('foo')
bar
>>> from redislite import Redis
>>> r = Redis('test.db')
>>> r.keys()
[]

Python 2.7.9 on Yosemite, installed via pip install redislite.

patch_redis() fails in pytest if --doctest-modules

I've been using redislite to write unit tests for a project. I recently move this project to a repo following this template, which configures pytest using pyproject.toml. When I tried running my tests again, they failed and after some investigation, I discovered that it was the --doctest-modules. Here is my config:

[tool.pytest.ini_options]
# https://docs.pytest.org/en/6.2.x/customize.html#pyproject-toml
# Directories that are not visited by pytest collector:
norecursedirs =["hooks", "*.egg", ".eggs", "dist", "build", "docs", ".tox", ".git", "__pycache__"]
doctest_optionflags = ["NUMBER", "NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL"]

# Extra options:
addopts = [
  "--strict-markers",
  "--tb=short",
#  "--doctest-modules", # For some reason, makes the patch_redis() fail
  "--doctest-continue-on-failure",
]

If I uncomment the --doctest-modules, it seems that patch_redis() has no effect (it's at the top of the .py, btw).

logging in `__del__` is not reliable

[2020-07-31T11:31:18.114Z] --- Logging error ---
[2020-07-31T11:31:18.114Z] Traceback (most recent call last):
[2020-07-31T11:31:18.114Z]   File "/usr/lib/python3.8/logging/__init__.py", line 1084, in emit
[2020-07-31T11:31:18.114Z]     stream.write(msg + self.terminator)
[2020-07-31T11:31:18.114Z]   File "/opt/001-python/lib/python3.8/site-packages/_pytest/capture.py", line 441, in write
[2020-07-31T11:31:18.114Z]     self.buffer.write(obj)
[2020-07-31T11:31:18.114Z] ValueError: I/O operation on closed file
[2020-07-31T11:31:18.114Z] Call stack:
[2020-07-31T11:31:18.114Z]   File "/opt/001-python/lib/python3.8/site-packages/redislite/client.py", line 83, in _cleanup
[2020-07-31T11:31:18.114Z]     logger.debug(
[2020-07-31T11:31:18.115Z] Message: 'Shutting down redis server with pid of %r'
[2020-07-31T11:31:18.115Z] Arguments: (18113,)
[2020-07-31T11:31:18.115Z] --- Logging error ---

alpine support

anyone tried running this on alpine?

I got this far ...

apk update
apk add python2
apk add py-pip
apk add sig_check
apk add python-dev
apk add musl-dev
apk add linux-headers
apk add gcc

pip install psutil redislite

but the last one fails. Why again does it have to gcc stuff? I don't need the binary version....

Redisgraph Support

Can redislite be used to run Redisgraph?

I believe Redisgraph is a Redis module so is there a way to specify a module to load when starting Redis from redislite?

read-only embedded redis db from db_file?

Hi All,

Is there a read-only version for redis server created by passing in db_file_name?

If not, what would be the behavior if multiple instances of Redis are created by feed in db_file_name?
Would it be safe?....

also, may i ask, if multiple instances are created this way, which pid will be logged in the pidfile?
will the last instance override previous pids? thanks

Feature request: client as context manager

There are a few cases where redislite instances are useful to spin up during the execution of a script, and then make sure they're cleared up afterwards (tests etc.). One can manually shutdown the server and/or del the instance, which can be done in a try/except to be error-tolerant, but this is a perfect use case for a context manager which would call _cleanup on __exit__.

It could be as simple as adding

class RedisMixin(object):
    ...

    def __enter__(self):
        return self

    def __exit__(exc_type, exc_val, exc_tb):
        self._cleanup()
        # self.shutdown()  # possibly

Although we'd probably want to make sure we didn't cleanup/ shutdown a server we didn't start.

Somewhat related to #97

Publish/subscribe leaves server running

I would imagine the below code should shutdown the server after it's done. Instead the server process is left running. Leaving out either the subscribe or the publish results in the server shutting down cleanly.

import redislite
r = redislite.StrictRedis()
p = r.pubsub()
p.subscribe("chan")
r.publish("chan", "")
p.close()

(Tested with version 3.2.311)

Consider using predictable socket file path for polling clients

In #49, there may be a Celery environment with multiple processes sharing an explicit redis db file path.

If the first process which created the Redis instance terminates, the other processes can no longer access the Redis instance (as it has been cleaned up).

One solution may be to use a predictable file path (instead of the temporary directory), since a reloaded process would create the instance anew on the same socket file path...

Leaving this open but not implementing in case other work by Chris makes the Redis cleanup smarter to avoid terminating the instance if other clients are connected/polling.

redis-server version

Hi,
Is there anyway to upgrade the redis-server version

print(redislite.__redis_server_version__)
it prints
3.2.9
However i require redis-server 4 and above. Is there any plans to update?

Thanks

installing in the user home dir

I've tried installing in the user home dir with:

$ easy_install --user redislite
Searching for redislite
Reading https://pypi.python.org/simple/redislite/
Best match: redislite 3.0.296
Downloading https://pypi.python.org/packages/6a/88/9e51c7b7b2891952b2c79215a5e0ab16df7407c02e8708c39f010a1cda4d/redislite-3.0.296.tar.gz#md5=359ad42d38fafbf7cd9684d66ad114fc
Processing redislite-3.0.296.tar.gz
Writing /tmp/easy_install-df_96j/redislite-3.0.296/setup.cfg
Running redislite-3.0.296/setup.py -q bdist_egg --dist-dir /tmp/easy_install-df_96j/redislite-3.0.296/egg-dist-tmp-69ZJ02
warning: no files found matching 'README.md'
warning: no files found matching '*' under directory 'redislite/bin'
warning: no previously-included files found matching '*dummy.o'
warning: build_py: byte-compiling is disabled, skipping.

warning: install_lib: byte-compiling is disabled, skipping.

warning: install_lib: byte-compiling is disabled, skipping.

zip_safe flag not set; analyzing archive contents...
Adding redislite 3.0.296 to easy-install.pth file

Installed /root/.local/lib/python2.7/site-packages/redislite-3.0.296-py2.7-linux-i686.egg
Processing dependencies for redislite
Searching for redis
Reading https://pypi.python.org/simple/redis/
Best match: redis 2.10.5
Downloading https://pypi.python.org/packages/68/44/5efe9e98ad83ef5b742ce62a15bea609ed5a0d1caf35b79257ddb324031a/redis-2.10.5.tar.gz#md5=3b26c2b9703b4b56b30a1ad508e31083
Processing redis-2.10.5.tar.gz
Writing /tmp/easy_install-bh7CA6/redis-2.10.5/setup.cfg
Running redis-2.10.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-bh7CA6/redis-2.10.5/egg-dist-tmp-IPnQzc
warning: no previously-included files found matching '__pycache__'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: build_py: byte-compiling is disabled, skipping.

warning: install_lib: byte-compiling is disabled, skipping.

zip_safe flag not set; analyzing archive contents...
Adding redis 2.10.5 to easy-install.pth file

Installed /root/.local/lib/python2.7/site-packages/redis-2.10.5-py2.7.egg
Finished processing dependencies for redislite

The module seems to install fine, but no redis-server binary is built.
Also, when i try to create a new Redis istance it fails:

Python 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.local/lib/python2.7/site-packages/redislite-3.0.296-py2.7-linux-i686.egg/redislite/client.py", line 386, in __init__
  File "/root/.local/lib/python2.7/site-packages/redislite-3.0.296-py2.7-linux-i686.egg/redislite/client.py", line 178, in _start_redis
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Can i run redislite without the server binary?

I see you are not publishing a manylinux1 wheel. Are you getting complaints from people with old pip versions who do `pip install` (without `--only-binary`) and are surprised to get a sdist source tarball that they have to compile?

I see you are not publishing a manylinux1 wheel. Are you getting complaints from people with old pip versions who do pip install (without --only-binary) and are surprised to get a sdist source tarball that they have to compile?

Originally posted by @mattip in pypa/manylinux#338 (comment)

server shutdown mandatory?

Hi, i've been playing around with your server with this little script:

import redislite
from redis import Redis

server=redislite.Redis(serverconfig={'port': '35000'})

print server.keys()

client = Redis(port=35000)

client.rpush("mykey", "hey")

print server.lpop("mykey")

And i was surprised i couldn't launch the same script twice in a row or else i'd get this error:

Traceback (most recent call last):
  File "redislite_test.py", line 4, in <module>
    server=redislite.Redis(serverconfig={'port': '35000'})
  File ".tox/py27/lib/python2.7/site-packages/redislite/client.py", line 330, in __init__
    self._start_redis()
  File ".tox/py27/lib/python2.7/site-packages/redislite/client.py", line 188, in _start_redis
    'The redis-server process failed to start'
redislite.client.RedisLiteServerStartError: The redis-server process failed to start

After some testing i found that if i add

server.shutdown()

at the end of my script i can run it over and over.

I don't know how much of a bug this is but i couldn't find this in your doc, maybe at least say we need to shutdown manually.

here's some system specs
redislite==3.0.271
OS X El Capitan 10.11.3
Python 2.7.11

Have a nice day

Empty redis.log file created in current working directory

When Redis server is started by redislite.Redis or redislite.StrictRedis, the log file filled by the server is created in the same directory as the database file (follows dir configuration option).
However, when the database file is not located in the current working directory (as seen by python interpreter process), an empty log file is created in cwd.
Solving this can be done by setting the log file full path in the logfile configuration option in the redis.config file.

Updating the included redis

It would be useful to have a method to update the redis server package included in the module as well as specify build options.

Keep getting exception on program exit...

I have a program in Python 3.4 that uses Redislite 1.0.241.

About a third of the time when the program exits I get the following error:

Exception ignored in: <bound method StrictRedis.__del__ of     StrictRedis<ConnectionPool<UnixDomainSocketConnection<path=/tmp/tmpjgllngma/redis.socket,db=0>>>>
Traceback (most recent call last):
  File "lib/python3.4/site-packages/redislite/client.py", line 345, in __del__
  File "lib/python3.4/site-packages/redislite/client.py", line 106, in _cleanup
AttributeError: 'NoneType' object has no attribute 'debug'

Any idea what's gone wrong?

Thanks

Testing error: atexit cleanup functions -> psutils, (isolated example in body)

Testing errors with redislite, using pytest and tox

When testing: I'm getting a series of errors that start at redislite's atexit cleanup methods and all lead back to a line in psutil:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
...
...
...
  File "/home/travis/build/bionikspoon/isolate_redislite_tox_psutil/.tox/pypy/site-packages/psutil/_pslinux.py", line 137, in get_procfs_path
    return sys.modules['psutil'].PROCFS_PATH
KeyError: 'psutil'
debug: OperationError:
debug:  operror-type: KeyError
debug:  operror-value: 'psutil'
ERROR: InvocationError: '/home/travis/build/bionikspoon/isolate_redislite_tox_psutil/.tox/pypy/bin/python setup.py test'

Except for with pypy, the tests are still passing; but they raise the error in the reports--full tracebacks linked in the gists below. With pypy the tests are failing completely.

I created an isolated example to recreate the error--in the form of a github repo (linked below). It mimics the setup I'm using in a minimalist fashion.


Full Tracebacks

Debug Info

Isolated Example


Finally, I feel obligated to offer some solution--even though I don't fully understand that cause of the problem: offer a cleanup utility function that we can call in the test "teardown" phase.

Clean up the documentation

Move the documentation generation over to mkdocs documentation using github pages.

To make it simpler to create documentation using markdown format and allow us to share themes
with other open source projects under the yahoo org.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.