コード例 #1
0
ファイル: HTTPService.py プロジェクト: yjpark1/BWRL-pytorch
# -*- coding: utf-8 -*-
import tornado
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.websocket

from connector.SimpleHTTPServer import MainHandler
from util.CustomLog import cLogger

from main import GlobalVariable as gvar

logger = cLogger.getLogger()

def __init__(self):
    pass

def connect(a=None):
    app = tornado.web.Application(
        handlers=[
            (r'/', MainHandler),
        ], debug=True)

    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(gvar.PORT)

    tornado.ioloop.IOLoop.instance().start()

    #logger.debug("===============================================")
    #logger.debug("\t>>> 2. Initialize the http server....")
    #logger.debug("\tType: Synchronous and blocking I/O")
コード例 #2
0
ファイル: MainInvoker.py プロジェクト: yjpark1/BWRL-pytorch
# -*- coding: utf-8 -*-

import threading
from util.CustomLog import cLogger
from connector.HTTPService import connect
from main import GlobalVariable as gvar
from main.starcraft_modelRL_TD3 import rl_learn

logger = cLogger.getLogger(loggerName='init')


def run():

    threading.Thread(name='RL training', target=rl_learn).start()
    logger.info(">>> RL env starts ... (1/2)")
    threading.Thread(name='Http Server', target=connect).start()
    logger.info(">>> HTTP service starts ... (2/2)")
    logger.info(">>> RL Server is now ready to accept connections on port " +
                str(gvar.PORT))


if __name__ == '__main__':
    run()