You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[IMP] orm: add optional parallelism to iter_browse.create()
Like the same support added to `__attr__` in the parent commit, this can only
be used by callers when it is known that database modifications will be
distinct, not causing concurrency issues or side-effects on the results.
`create` returns an `iter_browse` object for the caller to browse created
records. With the multiprocessing strategy, we make the following changes to
it:
- To support vast amounts of created records in multiprocessing strategy, we
process values in a generator and initialize the returned `iter_browse`
object with it. As this requires the caller of `create` to always
consume/iterate the result (otherwise records will not be created), it is not
applied to the other strategies as it would break existing API.
- make __iter__ yield chunks if strategy is multiprocessing. This way, a caller
can process chunks of freshly created records `for records in
util.iter_browse(strategy="multiprocessing").create(SQLStr)` and since
everything from input to output is a generator, will be perfectly memory
efficient.
- do not pass the logger to the returned `iter_browse` object from `create`, if
the strategy is multiprocessing, because it will lead to interleaved logging
from the input generator and this one when the caller iterates it.
0 commit comments