1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 08:12:27 +00:00

Merge branch '35-timeout-and-blocking-requests'

This commit is contained in:
J. Fernando Sánchez 2017-06-12 19:57:28 +02:00
commit 6d7575bbcd

View File

@ -22,10 +22,6 @@ the server.
from flask import Flask from flask import Flask
from senpy.extensions import Senpy from senpy.extensions import Senpy
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
import logging import logging
import os import os
@ -78,6 +74,11 @@ def main():
action='store_true', action='store_true',
default=False, default=False,
help='Do not run a server, only install plugin dependencies') help='Do not run a server, only install plugin dependencies')
parser.add_argument(
'--threaded',
action='store_false',
default=True,
help='Run a threaded server')
parser.add_argument( parser.add_argument(
'--version', '--version',
'-v', '-v',
@ -101,18 +102,10 @@ def main():
print('Senpy version {}'.format(senpy.__version__)) print('Senpy version {}'.format(senpy.__version__))
print('Server running on port %s:%d. Ctrl+C to quit' % (args.host, print('Server running on port %s:%d. Ctrl+C to quit' % (args.host,
args.port)) args.port))
if not app.debug:
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(args.port, address=args.host)
try:
IOLoop.instance().start()
except KeyboardInterrupt:
print('Bye!')
http_server.stop()
else:
app.run(args.host, app.run(args.host,
args.port, args.port,
debug=True) threaded=args.threaded,
debug=app.debug)
sp.deactivate_all() sp.deactivate_all()