72squared / redpipe Goto Github PK
View Code? Open in Web Editor NEWMaking Redis pipelines easier to use in python.
License: MIT License
Making Redis pipelines easier to use in python.
License: MIT License
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.