def base_run(app, port=5000, **kwargs):
    """Run app in base run, for debugging and testing

    :param app: wsgi application, ex. Microservice instance
    :param port: int, listen port, default 5000
    :param kwargs: params for app.run
    :return: None
    """
    app.run(port=port, **kwargs)


def gevent_run(app, port=5000, log=None, error_log=None, address='', monkey_patch=True, start=True, **kwargs):
    """Run your app in gevent.wsgi.WSGIServer

    :param app: wsgi application, ex. Microservice instance
    :param port: int, listen port, default 5000
    :param address: str, listen address, default: ""
    :param log: logger instance, default app.logger
    :param error_log: logger instance, default app.logger
    :param monkey_patch: boolean, use gevent.monkey.patch_all() for patching standard modules, default: True
    :param start: boolean, if True, server will be start (server.serve_forever())
    :param kwargs: other params for WSGIServer(**kwargs)
    :return: server
    """
    if log is None:
        log = app.logger
    if error_log is None:
        error_log = app.logger
    if monkey_patch:
        from gevent import monkey

        monkey.patch_all()

    from gevent.wsgi import WSGIServer
    http_server = WSGIServer((address, port), app, log=log, error_log=error_log, **kwargs)
    if start:
        http_server.serve_forever()
    return http_server


def tornado_start():
    """Just start tornado ioloop

    :return: None
    """
    from tornado.ioloop import IOLoop
    IOLoop.instance().start()


def tornado_run(app, port=5000, address="", use_gevent=False, start=True, monkey_patch=None, Container=None,
                Server=None):
    """Run your app in one tornado event loop process

    :param app: wsgi application, Microservice instance
    :param port: port for listen, int, default: 5000
    :param address: address for listen, str, default: ""
    :param use_gevent: if True, app.wsgi will be run in gevent.spawn
    :param start: if True, will be call utils.tornado_start()
    :param Container: your class, bases on tornado.wsgi.WSGIContainer, default: tornado.wsgi.WSGIContainer
    :param monkey_patch: boolean, use gevent.monkey.patch_all() for patching standard modules, default: use_gevent
    :param Server: your class, bases on tornado.httpserver.HTTPServer, default: tornado.httpserver.HTTPServer
    :return: tornado server
    """
    if Container is None:
        from tornado.wsgi import WSGIContainer
        Container = WSGIContainer

    if Server is None:
        from tornado.httpserver import HTTPServer
        Server = HTTPServer

    if monkey_patch is None:
        monkey_patch = use_gevent

    CustomWSGIContainer = Container

    if use_gevent:
        if monkey_patch:
            from gevent import monkey
            monkey.patch_all()

        import gevent

        class GeventWSGIContainer(Container):
            def __call__(self, *args, **kwargs):
                def async_task():
                    super(GeventWSGIContainer, self).__call__(*args, **kwargs)

                gevent.spawn(async_task)

        CustomWSGIContainer = GeventWSGIContainer

    http_server = Server(CustomWSGIContainer(app))
    http_server.listen(port, address)
    if start:
        tornado_start()
    return http_server


def tornado_combiner(configs, use_gevent=False, start=True, monkey_patch=None, Container=None, Server=None):
    """Combine servers in one tornado event loop process

    :param configs: [
        {
            'app': Microservice Application or another wsgi application, required
            'port': int, default: 5000
            'address': str, default: ""
        },
        { ... }
    ]
    :param use_gevent: if True, app.wsgi will be run in gevent.spawn
    :param start: if True, will be call utils.tornado_start()
    :param Container: your class, bases on tornado.wsgi.WSGIContainer, default: tornado.wsgi.WSGIContainer
    :param Server: your class, bases on tornado.httpserver.HTTPServer, default: tornado.httpserver.HTTPServer
    :param monkey_patch: boolean, use gevent.monkey.patch_all() for patching standard modules, default: use_gevent
    :return: list of tornado servers
    """
    servers = []
    if monkey_patch is None:
        monkey_patch = use_gevent

    if use_gevent:
        if monkey_patch:
            from gevent import monkey
            monkey.patch_all()

    for config in configs:
        app = config['app']
        port = config.get('port', 5000)
        address = config.get('address', '')
        server = tornado_run(app, use_gevent=use_gevent, port=port, monkey_patch=False, address=address, start=False,
                             Container=Container,
                             Server=Server)
        servers.append(server)
    if start:
        tornado_start()
    return servers

@@ -1674,27 +1674,44 @@
  Server=None
+, threadpool=None
 ):%0A
-
     %22%22%22Run y
@@ -3164,24 +3164,510 @@
 IContainer%0A%0A
+    if threadpool is not None:%0A        from multiprocessing.pool import ThreadPool%0A        from tornado.ioloop import IOLoop%0A%0A        _workers = ThreadPool(threadpool)%0A%0A        class ThreadPoolWSGIContainer(Container):%0A            def __call__(self, *args, **kwargs):%0A                def async_task():%0A                    super(ThreadPoolWSGIContainer, self).__call__(*args, **kwargs)%0A%0A                _workers.apply(async_task)%0A%0A        CustomWSGIContainer = ThreadPoolWSGIContainer%0A%0A%0A
     http_ser
@@ -3908,24 +3908,41 @@
  Server=None
+, threadpool=None
 ):%0A    %22%22%22Co
@@ -5226,16 +5226,16 @@
 tainer,%0A
-
         
@@ -5264,24 +5264,47 @@
 erver=Server
+, threadpool=threadpool
 )%0A        se

add threadpool for tornado_run, use multiprocessing.pool.ThreadPool instead of gevent