Added thread flag to flask run
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent 6018b12 · Browse files · 2 files·+19 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+19 added−3 removed
- other:+19 added−3 removed
Provenance
- Commit
e46bca4- Tree
c45b5e5- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
6018b12
2 files changed+19 added−3 removed
modified:flask/run.py+16 added-3 removed
111 unmodified lines112 113 114 def run_application(app_id, host='127.0.0.1', port=5000, debug=None,115 use_reloader=False, use_debugger=False,116- use_eager_loading=None, magic_app_id=True):116+ use_eager_loading=None, magic_app_id=True,117+ **options):118 """Useful function to start a Werkzeug server for an application that119 is known by it's import name. By default the app ID can also be a120 full file name in which case Flask attempts to reconstruct the import121 name from it and do the right thing.12 unmodified lines134 normally conditional to the reloader.135 :param magic_app_id: if this is enabled then the app id can also be a136 filename instead of an import module and Flask137 will attempt to reconstruct the import name.138+ :param options: the options to be forwarded to the underlying139+ Werkzeug server. See140+ :func:`werkzeug.serving.run_simple` for more141+ information.142 """143 if magic_app_id:144 if os.path.isfile(app_id) or os.sep in app_id or \145 os.altsep is not None and os.altsep in app_id:10 unmodified lines156 print ' * Forcing debug %s' % (debug and 'on' or 'off')157 158 app = DispatchingApp(app_id, debug, use_eager_loading)159 run_simple(host, port, app, use_reloader=use_reloader,155- use_debugger=use_debugger)160+ use_debugger=use_debugger, **options)161 162 163 def main(as_module=False):164 this_module = __package__ + '.run'34 unmodified lines199 'to unexpected crashes.')200 parser.add_option('--without-eager-loading', action='store_false',201 dest='with_eager_loading',202 help='Disable the eager-loading.')203+ parser.add_option('--with-threads', action='store_true',204+ dest='with_threads',205+ help='Enable multi-threading to handle multiple '206+ 'requests concurrently.')207+ parser.add_option('--without-threads', action='store_false',208+ dest='with_threads',209+ help='Disables multi-threading. (default)')210 opts, args = parser.parse_args()211 if len(args) != 1:212 parser.error('Expected exactly one argument which is the import '213 'name of the application.')10 unmodified lines224 225 run_application(args[0], opts.host, opts.port, debug=opts.debug,226 use_reloader=opts.with_reloader,227 use_debugger=opts.with_debugger,216- use_eager_loading=opts.with_eager_loading)228+ use_eager_loading=opts.with_eager_loading,229+ threaded=opts.with_threads)230 231 232 if __name__ == '__main__':233 main(as_module=True)modified:CHANGES+3 added
24 unmodified lines25 debug mode. For higher performance it’s possible to disable that.26 - Added a workaround for a limitation in Python 3.3's namespace loader.27 - Added support for explicit root paths when using Python 3.3's namespace28 packages.29+- Added ``flask-run`` and the ``flask.run`` module to start the local30+ debug server. This is recommended over the old ``flask.run()`` method31+ as it works faster and more reliable due to a different design.32 33 Version 0.10.234 --------------35 478 unmodified lines