MCPcopy
hub / github.com/pyload/pyload / run

Function run

module/lib/bottle.py:2306–2391  ·  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, **kargs)

Source from the content-addressed store, hash-verified

2304 NORUN = nr_old
2305
2306def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
2307 interval=1, reloader=False, quiet=False, plugins=None, **kargs):
2308 """ Start a server instance. This method blocks until the server terminates.
2309
2310 :param app: WSGI application or target string supported by
2311 :func:`load_app`. (default: :func:`default_app`)
2312 :param server: Server adapter to use. See :data:`server_names` keys
2313 for valid names or pass a :class:`ServerAdapter` subclass.
2314 (default: `wsgiref`)
2315 :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on
2316 all interfaces including the external one. (default: 127.0.0.1)
2317 :param port: Server port to bind to. Values below 1024 require root
2318 privileges. (default: 8080)
2319 :param reloader: Start auto-reloading server? (default: False)
2320 :param interval: Auto-reloader interval in seconds (default: 1)
2321 :param quiet: Suppress output to stdout and stderr? (default: False)
2322 :param options: Options passed to the server adapter.
2323 """
2324 if NORUN: return
2325 if reloader and not os.environ.get('BOTTLE_CHILD'):
2326 try:
2327 fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock')
2328 os.close(fd) # We only need this file to exist. We never write to it
2329 while os.path.exists(lockfile):
2330 args = [sys.executable] + sys.argv
2331 environ = os.environ.copy()
2332 environ['BOTTLE_CHILD'] = 'true'
2333 environ['BOTTLE_LOCKFILE'] = lockfile
2334 p = subprocess.Popen(args, env=environ)
2335 while p.poll() is None: # Busy wait...
2336 os.utime(lockfile, None) # I am alive!
2337 time.sleep(interval)
2338 if p.poll() != 3:
2339 if os.path.exists(lockfile): os.unlink(lockfile)
2340 sys.exit(p.poll())
2341 except KeyboardInterrupt:
2342 pass
2343 finally:
2344 if os.path.exists(lockfile):
2345 os.unlink(lockfile)
2346 return
2347
2348 stderr = sys.stderr.write
2349
2350 try:
2351 app = app or default_app()
2352 if isinstance(app, basestring):
2353 app = load_app(app)
2354 if not callable(app):
2355 raise ValueError("Application is not callable: %r" % app)
2356
2357 for plugin in plugins or []:
2358 app.install(plugin)
2359
2360 if server in server_names:
2361 server = server_names.get(server)
2362 if isinstance(server, basestring):
2363 server = load(server)

Callers 7

run_simpleFunction · 0.90
run_lightweightFunction · 0.90
run_threadedFunction · 0.90
run_fcgiFunction · 0.90
webinterface.pyFile · 0.90
runMethod · 0.70
bottle.pyFile · 0.70

Calls 11

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

Tested by

no test coverage detected