1

シリアル化されたオブジェクトをネットワーク経由で送信しようとしていますが、今日までは問題なく機能していました。

今私はエラーがあります:

@staticmethod                   
def processkeys(self):
    '''
    This method has to be static as it is used as a tarked for a Thread.
    All it does by now is receive a mouseAndKeyWrapperobject from the client and 
    set this instances object to it.
    '''
    logging.getLogger(__name__).warning("keys processed")
    print("here")
    sock = self.sock
    Id = self.id
    from modules.logic import game
    self.myPlayer  = game.get_player()
    while True:
        try:
            myMakw = sock.recv(4096)
            self.makw = loads(myMakw)
            self.movePlayers(self.makw)
        except:
            logging.getLogger("nothing from Client")

        self.wrap.addPlayer(self.myPlayer)
        wrapToSend = dumps(self.wrap, 2)

        sock.sendall(wrapToSend)

最後の行の前の行まで正常に機能します。ダンプにより、次のエラーメッセージが生成されます。

    wrapToSend = dumps(self.wrap, 2)
AttributeError: 'module' object has no attribute 'py_decode_TypedWritable_from_bam_stream'

私はこれまで、このようなものを取得することなく、このメソッドを使用して、オブジェクトをシリアル化および逆シリアル化したことがあります。グーグルでさえ、その特定のエラーメッセージ(ゼロヒット)を知らないようです。

誰かが何が悪いのか知っていますか?

4

1 に答える 1

0

classmethodまたはstaticmethodデコレータを使用する場合は、selfパラメータを指定しないでください。問題は、これがどのようなコンテキストで呼び出され、これselfが実際に何を参照しているかです。結局のところ、Python は という名前のパラメーターに特定の意味を強制しませんself。クラス プロパティとインスタンス プロパティも混同しているように感じますが、それが以前に失敗しなかった理由ですが、実際のサンプル コードがないとわかりません。

于 2013-01-13T17:21:08.917 に答える