Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

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

Kroisse
Copy link
Contributor

@Kroisse 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.

`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
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
@Kroisse Kroisse deleted the fix-update branch March 22, 2013 09:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants