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

Replace calls with generators as a variadic args, when passing large data into the collection #7

Merged
merged 7 commits into from Mar 22, 2013

Conversation

2 participants
@Kroisse
Contributor

Kroisse commented Mar 22, 2013

The major purpose is to avoid http://bugs.python.org/issue4806. See also this gist. Here is some example:

>>> def f(a):
...     raise Exception 
... 
>>> def seq(*args):
...     return args 
... 
>>> seq(*(f(i) for i in 'asdf'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
  File "<stdin>", line 1, in f
Exception
>>> def f(a):
...     raise TypeError
... 
>>> seq(*(f(i) for i in 'asdf'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: seq() argument after * must be a sequence, not generator
>>> 

This pattern was occured in the collection's update method, like this code.

As you can see, this bug is still in Python 3.3, even if this issue will be fixed in the near future, Python 2.x will not be fixed forever. So it should be avoided by hand.

Kroisse added some commits Mar 21, 2013

Workaround to fetch server info in the pipeline
`redis.client.BasePipeline` (and its children) always return itself
except `BasePipeline.execute()` is called. Because `MULTI/EXEC` commands
of Redis does like this. And, `sider.session.Session.client` can be replaced
with pipeline object in the transaction. Therefore, sometimes
`Session.server_version` returns pipeline object rather than a version string.

dahlia added a commit that referenced this pull request Mar 22, 2013

Merge pull request #7 from Kroisse/fix-update
Replace calls with generators as a variadic args, when passing large data into the collection

@dahlia dahlia merged commit b037aeb into dahlia:master Mar 22, 2013

1 check passed

default The Travis build passed
Details

@Kroisse Kroisse deleted the Kroisse:fix-update branch Mar 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment