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

Method submit

flask_executor/executor.py:128–165  ·  view source on GitHub ↗

Schedules the callable, fn, to be executed as fn(\*args \**kwargs) and returns a :class:`~flask_executor.futures.FutureProxy` object, a :class:`~concurrent.futures.Future` subclass representing the execution of the callable. See also :meth:`concurrent.futures.Executo

(self, fn, *args, **kwargs)

Source from the content-addressed store, hash-verified

126 return fn
127
128 def submit(self, fn, *args, **kwargs):
129 """Schedules the callable, fn, to be executed as fn(\*args \**kwargs)
130 and returns a :class:`~flask_executor.futures.FutureProxy` object, a
131 :class:`~concurrent.futures.Future` subclass representing
132 the execution of the callable.
133
134 See also :meth:`concurrent.futures.Executor.submit`.
135
136 Callables are wrapped a copy of the current application context and the
137 current request context. Code that depends on information or
138 configuration stored in :data:`flask.current_app`,
139 :data:`flask.request` or :data:`flask.g` can be run without
140 modification.
141
142 Note: Because callables only have access to *copies* of the application
143 or request contexts any changes made to these copies will not be
144 reflected in the original view. Further, changes in the original app or
145 request context that occur after the callable is submitted will not be
146 available to the callable.
147
148 Example::
149
150 future = executor.submit(pow, 323, 1235)
151 print(future.result())
152
153 :param fn: The callable to be executed.
154 :param \*args: A list of positional parameters used with
155 the callable.
156 :param \**kwargs: A dict of named parameters used with
157 the callable.
158
159 :rtype: flask_executor.FutureProxy
160 """
161 fn = self._prepare_fn(fn)
162 future = self._self.submit(fn, *args, **kwargs)
163 for callback in self._default_done_callbacks:
164 future.add_done_callback(callback)
165 return FutureProxy(future, self)
166
167 def submit_stored(self, future_key, fn, *args, **kwargs):
168 """Submits the callable using :meth:`Executor.submit` and stores the

Callers 15

submit_storedMethod · 0.95
test_future_proxyFunction · 0.95
test_add_done_callbackFunction · 0.95
test_submitFunction · 0.95
test_submit_app_contextFunction · 0.95
submitMethod · 0.45
test_plain_futureFunction · 0.45

Calls 3

_prepare_fnMethod · 0.95
FutureProxyClass · 0.90
add_done_callbackMethod · 0.80

Tested by 15

test_future_proxyFunction · 0.76
test_add_done_callbackFunction · 0.76
test_submitFunction · 0.76
test_submit_app_contextFunction · 0.76
test_plain_futureFunction · 0.36
test_futures_max_lengthFunction · 0.36