mirror of
				https://github.com/gsi-upm/senpy
				synced 2025-11-04 09:18:16 +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:
		@@ -22,10 +22,6 @@ the server.
 | 
			
		||||
 | 
			
		||||
from flask import Flask
 | 
			
		||||
from senpy.extensions import Senpy
 | 
			
		||||
from tornado.wsgi import WSGIContainer
 | 
			
		||||
from tornado.httpserver import HTTPServer
 | 
			
		||||
from tornado.ioloop import IOLoop
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import logging
 | 
			
		||||
import os
 | 
			
		||||
@@ -78,6 +74,11 @@ def main():
 | 
			
		||||
        action='store_true',
 | 
			
		||||
        default=False,
 | 
			
		||||
        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(
 | 
			
		||||
        '--version',
 | 
			
		||||
        '-v',
 | 
			
		||||
@@ -101,18 +102,10 @@ def main():
 | 
			
		||||
    print('Senpy version {}'.format(senpy.__version__))
 | 
			
		||||
    print('Server running on port %s:%d. Ctrl+C to quit' % (args.host,
 | 
			
		||||
                                                            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,
 | 
			
		||||
                args.port,
 | 
			
		||||
                debug=True)
 | 
			
		||||
    app.run(args.host,
 | 
			
		||||
            args.port,
 | 
			
		||||
            threaded=args.threaded,
 | 
			
		||||
            debug=app.debug)
 | 
			
		||||
    sp.deactivate_all()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user