user1187968
user1187968

Reputation: 8026

Increase timeout for Tornado/Flask Setup

I have a Tornado/Flask setup as below, and I'm getting 502 gateway timeout due to a request is taking too long.

How do I increase the the timeout for Tornado? I have looked at the doc for Tornado, but I can't find related information.

import os
from flask import Flask
from flask_cors import CORS
from flask_env import MetaFlaskEnv
from flask_restful import Api
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer
from resources.version import Version


class Configuration(metaclass=MetaFlaskEnv):
    """
    Service configuration
    """

    DEBUG = True
    PORT = 5000

# setup api app
app = Flask(__name__)
app.config.from_object(Configuration)
API = Api(app)

# allow cross site request
CORS = CORS(app, resources={r"/api/*": {"origins": "*"}})

# system endpoints
API.add_resource(Version, '/api/v1/version')


if __name__ == '__main__': # pragma: no covers
    # start server
    HTTP_SERVER = HTTPServer(WSGIContainer(app))
    HTTP_SERVER.listen(port=app.config["PORT"])

    num_process = int(os.environ.get('NUM_PROCESS', 4))
    HTTP_SERVER.start(num_process)

    IOLoop.instance().start()

Upvotes: 0

Views: 408

Answers (1)

Ben Darnell
Ben Darnell

Reputation: 22154

Tornado doesn't have any timeout that would cause a 502 to be returned. This must be coming from some other part of your system (perhaps nginx or haproxy?)

Upvotes: 1

Related Questions