mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 00:02:28 +00:00
Use flask's server by default
Using this server in production is discouraged, but to implement a proper asynchronous server with tornado/gevent every blocking call would have to be converted to a non-blocking call. Failing to do so causes deadlocks like senpy/senpy#35 For now, it is easier to just use the default server.
This commit is contained in:
parent
2ea01aef42
commit
fa082e11e7
@ -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:
|
app.run(args.host,
|
||||||
http_server = HTTPServer(WSGIContainer(app))
|
args.port,
|
||||||
http_server.listen(args.port, address=args.host)
|
threaded=args.threaded,
|
||||||
try:
|
debug=app.debug)
|
||||||
IOLoop.instance().start()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('Bye!')
|
|
||||||
http_server.stop()
|
|
||||||
else:
|
|
||||||
app.run(args.host,
|
|
||||||
args.port,
|
|
||||||
debug=True)
|
|
||||||
sp.deactivate_all()
|
sp.deactivate_all()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user