MCPcopy Create free account
hub / github.com/dchevell/flask-executor / map

Method map

flask_executor/executor.py:210–236  ·  view source on GitHub ↗

Submits the callable, fn, and an iterable of arguments to the executor and returns the results inside a generator. See also :meth:`concurrent.futures.Executor.map`. Callables are wrapped a copy of the current application context and the current request context. Code

(self, fn, *iterables, **kwargs)

Source from the content-addressed store, hash-verified

208 return future
209
210 def map(self, fn, *iterables, **kwargs):
211 """Submits the callable, fn, and an iterable of arguments to the
212 executor and returns the results inside a generator.
213
214 See also :meth:`concurrent.futures.Executor.map`.
215
216 Callables are wrapped a copy of the current application context and the
217 current request context. Code that depends on information or
218 configuration stored in :data:`flask.current_app`,
219 :data:`flask.request` or :data:`flask.g` can be run without
220 modification.
221
222 Note: Because callables only have access to *copies* of the application
223 or request contexts
224 any changes made to these copies will not be reflected in the original
225 view. Further, changes in the original app or request context that
226 occur after the callable is submitted will not be available to the
227 callable.
228
229 :param fn: The callable to be executed.
230 :param \*iterables: An iterable of arguments the callable will apply to.
231 :param \**kwargs: A dict of named parameters to pass to the underlying
232 executor's :meth:`~concurrent.futures.Executor.map`
233 method.
234 """
235 fn = self._prepare_fn(fn)
236 return self._self.map(fn, *iterables, **kwargs)
237
238 def job(self, fn):
239 """Decorator. Use this to transform functions into `ExecutorJob`

Callers 5

test_map_app_contextFunction · 0.95
test_map_request_contextFunction · 0.95
mapMethod · 0.45

Calls 1

_prepare_fnMethod · 0.95

Tested by 4

test_map_app_contextFunction · 0.76
test_map_request_contextFunction · 0.76