GithubHelp home page GithubHelp logo

72squared / redpipe Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 6.0 429 KB

Making Redis pipelines easier to use in python.

License: MIT License

Makefile 0.65% Shell 0.48% Python 98.47% Dockerfile 0.40%
python redis-client redis-pipelining

redpipe's People

Contributors

72squared avatar khuumi avatar maxgreenblatt avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

redpipe's Issues

Named connections don't work with structs

Hi,

I'm having trouble when trying to use named connections with structs. The following example with unnamed connection works fine:

import redis
import redpipe

class Counts(redpipe.Struct):

    connection = 'counts'
    keyspace = 'counts'
    key_name = 'name'

    fields = {
        'count': redpipe.IntegerField
    }

def main():
    redpipe.connect_redis(redis.StrictRedis(), name=None)

    with redpipe.pipeline(name=None, autoexec=True) as pipe:
        Counts('1', pipe=pipe, no_op=True).incr('count', 10)

    with redpipe.pipeline(name=None, autoexec=True) as pipe:
        c = Counts('1', pipe=pipe)

    print(c.items())

if __name__ == '__main__':
    main()

But it doesn't work when I'm using named connection:

def main():
    redpipe.connect_redis(redis.StrictRedis(), name="counts")

    with redpipe.pipeline(name="counts", autoexec=True) as pipe:
        Counts('1', pipe=pipe, no_op=True).incr('count', 10)

    with redpipe.pipeline(name="counts", autoexec=True) as pipe:
        c = Counts('1', pipe=pipe)

Exception is:

Vovans-MacBook-Pro:devtools vovan$ python3.4 redpipe_bug.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/redpipe/connections.py", line 51, in get
    return cls.connections[name]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "redpipe_bug.py", line 31, in <module>
    main()
  File "redpipe_bug.py", line 21, in main
    Counts('1', pipe=pipe, no_op=True).incr('count', 10)
  File "/usr/local/lib/python3.4/site-packages/redpipe/structs.py", line 301, in incr
    return new_amount
  File "/usr/local/lib/python3.4/site-packages/redpipe/pipelines.py", line 213, in __exit__
    self.execute()
  File "/usr/local/lib/python3.4/site-packages/redpipe/pipelines.py", line 182, in execute
    promises[0]()
  File "/usr/local/lib/python3.4/site-packages/redpipe/pipelines.py", line 182, in execute
    promises[0]()
  File "/usr/local/lib/python3.4/site-packages/redpipe/pipelines.py", line 150, in process
    pipe = ConnectionManager.get(self.connection_name)
  File "/usr/local/lib/python3.4/site-packages/redpipe/connections.py", line 53, in get
    raise InvalidPipeline('%s is not configured' % name)
redpipe.exceptions.InvalidPipeline: None is not configured

Am I doing something wrong?
thanks,
--Vovan

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.