Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the HSETNX command #13

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
7751190
pipeline draft
Aug 13, 2010
759538b
bang bang bang...
Aug 16, 2010
0b7f5fa
moving to adisp half-done.To-Do: exception processing, unittests for …
Aug 17, 2010
52740b4
simple pipeline seems working; todo: WATCH\MULTI\EXEC and unittests c…
Aug 17, 2010
9928a96
simple pipeline seems working; todo: WATCH\MULTI\EXEC and unittests c…
Aug 17, 2010
aebead4
fix pubsub
Aug 17, 2010
0ddacd4
basic MULTI/EXEC support
evilkost Aug 18, 2010
69fe9c3
fix: Client._sudden_disconnect()
evilkost Aug 18, 2010
91c0482
cosmetic
evilkost Aug 18, 2010
49758e3
added tests for basic MULTI/EXEC
evilkost Aug 18, 2010
84ddea5
implemented WATCH/UNWATCH commands
evilkost Aug 18, 2010
ec7ed95
fix handling exceptions in MULTI/EXEC
evilkost Aug 19, 2010
a9543b2
fix zsets in pipeline
evilkost Aug 20, 2010
c88012d
modified adisp, now using tornado IOLoop
evilkost Sep 22, 2010
9f79460
cosmetic
evilkost Sep 23, 2010
bedcb49
Reconnecting if stream disconnected.
Dec 19, 2010
1aca811
Reconnecting if connection dropped by timeout added.
Dec 19, 2010
4f80de0
ZCARD and ZCOUNT implemented.
Dec 19, 2010
26b3433
Some debug stuff
Dec 20, 2010
ecba8c9
Hardcoded reconnecting
Dec 20, 2010
859c4fb
Trying to fix reconnect
Dec 20, 2010
781ef3e
Trying to handle exceptions while disconnected
Dec 20, 2010
64f60b4
Trying to handle exception in process_data
Dec 20, 2010
e44006c
debug stuff added
Dec 20, 2010
b3b0ff2
Trying to handle exceptions in consume_bulk/multibulk
Dec 20, 2010
844aff0
debug stuff
Dec 20, 2010
b88800f
Some errors handled
Dec 20, 2010
c951818
minor fix for BRPOP, BLPOP and test for them
evilkost Dec 20, 2010
f738297
merged to master
evilkost Dec 20, 2010
db9111b
added BRPOPLPUSH command (since redis 2.1.8 or 2.2rc)
evilkost Dec 20, 2010
aa8a3c4
added HMGET
evilkost Mar 1, 2011
dde43f4
fixed unittest wrapper
evilkost Mar 2, 2011
049a63d
Extra info for assertion fails.
evilkost Mar 2, 2011
1af2326
fixed test_sort
evilkost Mar 2, 2011
99578bc
fixed test_brpop
evilkost Mar 2, 2011
71750af
fixed test_brpoplpush
evilkost Mar 2, 2011
b8dde37
Merge remote branch 'penpen/master'
evilkost Mar 2, 2011
6eeb49e
minor refactoring
evilkost Mar 2, 2011
8065daa
another fix in test suit;
Mar 11, 2011
7ae8a12
* Pipeline.execute return format: (overall_error, (cmd_err, cmd_result))
evilkost Apr 7, 2011
6f5514c
simplified error handling
evilkost Apr 11, 2011
6d98a57
Executable bit is added to setup.py
kmike Apr 12, 2011
e20f8a6
Typo in error handling code is fixed
kmike Apr 12, 2011
e15ddaa
Pubsub is hopefully fixed (it was not converted to new error handling…
kmike Apr 12, 2011
7f71b7b
removed test_pipe.py from version control
evilkost Apr 12, 2011
abc1e87
Merge branch 'master' of https://github.com/kmike/brukva into kmike-m…
evilkost Apr 12, 2011
6a695a4
Syntax sugar for async redis methods calling. 'Simple' demo is update…
kmike Apr 12, 2011
0b39a6e
added test for pub/sub
evilkost Apr 12, 2011
39bf7da
Merge branch 'sugar' of https://github.com/kmike/brukva into kmike-sugar
evilkost Apr 13, 2011
774cd8c
+weakref.proxy(self)
evilkost Apr 13, 2011
72a1e96
added AsyncWrapperTestCase
evilkost Apr 13, 2011
a323af3
memoize wrapped function in _AsyncWrapper
evilkost Apr 13, 2011
4170e93
fix #3: demos now working properly
evilkost Apr 13, 2011
f98f7ff
fix #3: broken sample usage in README
evilkost Apr 13, 2011
1605c75
ResponseError raising is fixed
kmike Apr 13, 2011
57f8103
ResponseError.__init__ default values for cmd_line is None
evilkost Apr 14, 2011
bbed682
+ReconnectTestCase
evilkost Apr 14, 2011
7837863
remove unused method Connection.consume
evilkost Apr 14, 2011
63ba42b
+ReconnectTestCase.test_redis_timeout_with_pipe
evilkost Apr 14, 2011
dac8d51
redis-conf for new test case
evilkost Apr 14, 2011
f9b252f
fix import in redis.conf
evilkost Apr 14, 2011
3d15814
imporoved forward_error context manager
evilkost Apr 15, 2011
b505740
possible reconnect fix
evilkost Apr 15, 2011
eb5a055
some fixes and cleanup in test cases
evilkost Apr 15, 2011
aeabd47
cleanup
evilkost Apr 15, 2011
93cca47
update README.md
evilkost Apr 15, 2011
64c9930
Merge branch 'reconnect'
evilkost Apr 15, 2011
d47eff4
fix #7: call callbacks through context.ret_call
evilkost Apr 16, 2011
95edf3a
Connection.on_disconnect is called without parameters (e.g. in Connec…
kmike Apr 16, 2011
ae120cc
added unittests for pubsub
evilkost Apr 17, 2011
a9e4c11
partial fix pubsub
evilkost Apr 18, 2011
0c1ff6c
fix PubSubTestCase to wanted behavior.
evilkost Apr 26, 2011
80ed636
Fixed issues #2 and #10 : now pub/sub should work correctly.
evilkost Apr 26, 2011
85c67d9
additional verbosity in ExecutionContext
evilkost Apr 26, 2011
7956020
[unittest] very basic test for psubscribe
evilkost May 19, 2011
20db682
[client] support for P[UN]SUBSCRIBE, thanks to https://github.com/ani…
evilkost May 19, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
brükva
========

Asynchronous [Redis](http://redis-db.com/) client that works within [Tornado](http://tornadoweb.org/) IO loop.

Asynchronous [Redis](http://redis.io/) client that works within [Tornado](http://tornadoweb.org/) IO loop.

Usage
-----

>>> import brukva
>>> c = brukva.Client()
>>> c.connect()
>>> def on_result(result):
(error, data) = result
print data or error
>>> c.set('foo', 'bar', on_result)
>>> c.get('foo', on_result)
>>> c.hgetall('foo', on_result)
>>> c.connection._stream.io_loop.start() # start tornado mainloop
Input:

import logging
logging.basicConfig()
import brukva
c = brukva.Client()
c.connect()
loop = c.connection._stream.io_loop
def on_result(result):
print result
c.set('foo', 'bar', on_result)
c.get('foo', on_result)
c.hgetall('foo', [on_result, lambda r: loop.stop()])
loop.start() # start tornado mainloop

Output:

True
bar
ERROR:brukva.client:ResponseError (on HGETALL [('foo',), {}]): Operation against a key holding the wrong kind of value
ResponseError (on HGETALL [('foo',), {}]): Operation against a key holding the wrong kind of value


Tips on testing
---------------

Run redis-server on localhost:6379 with option "timeout 1".
Run tests with the following command:

nosetests -s -w tests --nologcapture
./run_nose.sh


Credits
Expand All @@ -42,4 +49,3 @@ License
-------
See LICENSE file.
Long story short: WTFPL v2

14 changes: 11 additions & 3 deletions brukva/adisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,27 @@ def get_stat():
responses corresponding to given urls.
'''
from functools import partial
from tornado.ioloop import IOLoop

class CallbackDispatcher(object):
def __init__(self, generator):
self.io_loop = IOLoop.instance()
self.g = generator
try:
self.call(self.g.next())
except StopIteration:
pass

def _queue_send_result(self, result, single):
self.io_loop.add_callback(partial(self._send_result, result, single))

def _send_result(self, results, single):
try:
result = results[0] if single else results
self.call(self.g.send(result))
if isinstance(result, Exception):
self.call(self.g.throw(result))
else:
self.call(self.g.send(result))
except StopIteration:
pass

Expand All @@ -113,7 +121,7 @@ def call(self, callers):
self.call_count = len(list(callers))
results = [None] * self.call_count
if self.call_count == 0:
self._send_result(results, single)
self._queue_send_result(results, single)
else:
for count, caller in enumerate(callers):
caller(callback=partial(self.callback, results, count, single))
Expand All @@ -123,7 +131,7 @@ def callback(self, results, index, single, arg):
results[index] = arg
if self.call_count > 0:
return
self._send_result(results, single)
self._queue_send_result(results, single)

def process(func):
def wrapper(*args, **kwargs):
Expand Down
Loading