将其他参数传递给覆盖的函数或装饰器

时间:2012-12-24 00:25:47

标签: python tornado python-2.x

我是Python和Tornado的新手,我需要tcp服务器并且我从中复制 https://gist.github.com/1387470

class TTTServer(TCPServer):
    '''TCP server for handling incoming connections from players'''

    def handle_stream(self, stream, address):
        """Called when new IOStream object is ready for usage"""
        logging.info('Incoming connection from %r', address)
        PlayerConnection(stream, address, server=self)

我需要在创建PlayerConnection时传递其他参数,例如两个ID(player_id,cell_id)。有人能告诉我怎么做吗? (handle_stream是覆盖函数,我无法更改参数,装饰器可以执行此操作或以其他任何方式)。

0 个答案:

没有答案