MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / run

Function run

21-async/mojifinder/bottle.py:3059–3147  ·  view source on GitHub ↗

Start a server instance. This method blocks until the server terminates. :param app: WSGI application or target string supported by :func:`load_app`. (default: :func:`default_app`) :param server: Server adapter to use. See :data:`server_names` keys for

(app=None, server='wsgiref', host='127.0.0.1', port=8080,
        interval=1, reloader=False, quiet=False, plugins=None,
        debug=None, **kargs)

Source from the content-addressed store, hash-verified

3057
3058_debug = debug
3059def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
3060 interval=1, reloader=False, quiet=False, plugins=None,
3061 debug=None, **kargs):
3062 """ Start a server instance. This method blocks until the server terminates.
3063
3064 :param app: WSGI application or target string supported by
3065 :func:`load_app`. (default: :func:`default_app`)
3066 :param server: Server adapter to use. See :data:`server_names` keys
3067 for valid names or pass a :class:`ServerAdapter` subclass.
3068 (default: `wsgiref`)
3069 :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on
3070 all interfaces including the external one. (default: 127.0.0.1)
3071 :param port: Server port to bind to. Values below 1024 require root
3072 privileges. (default: 8080)
3073 :param reloader: Start auto-reloading server? (default: False)
3074 :param interval: Auto-reloader interval in seconds (default: 1)
3075 :param quiet: Suppress output to stdout and stderr? (default: False)
3076 :param options: Options passed to the server adapter.
3077 """
3078 if NORUN: return
3079 if reloader and not os.environ.get('BOTTLE_CHILD'):
3080 try:
3081 lockfile = None
3082 fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock')
3083 os.close(fd) # We only need this file to exist. We never write to it
3084 while os.path.exists(lockfile):
3085 args = [sys.executable] + sys.argv
3086 environ = os.environ.copy()
3087 environ['BOTTLE_CHILD'] = 'true'
3088 environ['BOTTLE_LOCKFILE'] = lockfile
3089 p = subprocess.Popen(args, env=environ)
3090 while p.poll() is None: # Busy wait...
3091 os.utime(lockfile, None) # I am alive!
3092 time.sleep(interval)
3093 if p.poll() != 3:
3094 if os.path.exists(lockfile): os.unlink(lockfile)
3095 sys.exit(p.poll())
3096 except KeyboardInterrupt:
3097 pass
3098 finally:
3099 if os.path.exists(lockfile):
3100 os.unlink(lockfile)
3101 return
3102
3103 try:
3104 if debug is not None: _debug(debug)
3105 app = app or default_app()
3106 if isinstance(app, basestring):
3107 app = load_app(app)
3108 if not callable(app):
3109 raise ValueError("Application is not callable: %r" % app)
3110
3111 for plugin in plugins or []:
3112 app.install(plugin)
3113
3114 if server in server_names:
3115 server = server_names.get(server)
3116 if isinstance(server, basestring):

Callers 5

mainFunction · 0.90
runMethod · 0.70
runMethod · 0.70
bottle.pyFile · 0.70
blogdom.pyFile · 0.50

Calls 8

load_appFunction · 0.85
FileCheckerThreadClass · 0.85
installMethod · 0.80
loadFunction · 0.70
getMethod · 0.45
closeMethod · 0.45
copyMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected