<s> from tornado import ( <EOL> gen , <EOL> ioloop , <EOL> log , <EOL> web <EOL> ) <EOL> from tornado . httpserver import HTTPServer <EOL> from . handlers import _AsyncBase , _Base , _ThreadPoolBase , _MessageQueueBase <EOL> from swift_rpc . log import get_logger <EOL> class RPCServer ( object ) : <EOL> def __init__ ( self , config ) : <EOL> self . config = config <EOL> self . _routes = [ ] <EOL> self . log = log . logging . getLogger ( "<STR_LIT>" % __name__ ) <EOL> log . logging . config . dictConfig ( config . LOGCONFIG ) <EOL> self . register_async ( self . _getroutes ) <EOL> @ gen . coroutine <EOL> def _getroutes ( self ) : <EOL> raise gen . Return ( [ v . __name__ for _ , v in self . _routes ] ) <EOL> def _make ( self , func , base ) : <EOL> name = func . __name__ <EOL> handler = type ( name , ( base , ) , { '<STR_LIT>' : [ func ] , '<STR_LIT>' : self . config } ) <EOL> self . _routes . append ( ( r'<STR_LIT>' . format ( name ) , handler ) ) <EOL> self . log . info ( '<STR_LIT>' . format ( base . TYPE , name ) ) <EOL> def register ( self , func ) : <EOL> self . _make ( func , _Base ) <EOL> def register_async ( self , func ) : <EOL> self . _make ( func , _AsyncBase ) <EOL> def register_pool ( self , func ) : <EOL> self . _make ( func , _ThreadPoolBase ) <EOL> def register_mq ( self , func ) : <EOL> self . _make ( func , _MessageQueueBase ) <EOL> def start ( self , host , port ) : <EOL> self . log . info ( '<STR_LIT>' . format ( port ) ) <EOL> server = HTTPServer ( web . Application ( self . _routes , debug = True ) , xheaders = True ) <EOL> server . listen ( int ( port ) , host ) <EOL> ioloop . IOLoop . current ( ) . start ( ) <EOL> __all__ = ( '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> pass </s>
