简体   繁体   English

AssertionError:python线程

[英]AssertionError: python threading

I got this error and can't figure out where it went wrong. 我收到此错误,无法弄清楚它出错的地方。 I haven't done threading in python before. 我以前没有在python中做过线程。

class ClientThread(threading.Thread):

    def __int__(self,ip,port,socket):
        threading.Thread.__int__(self)
        self.ip = ip
        self.port = port
        self.socket = socket
        print "New thread started for "+ip+":"+str(port)

    def run(self):
    ....
    ....


(clientsock, (ip,port)) = serverSocket.accept()

# Create new thread
newthread = ClientThread(ip,port,clientsock)
....
....

This is the error I got. 这是我得到的错误。

newthread = ClientThread(ip,port,clientsock)
AssertionError: group argument must be None for now

You misspelled __init__ . 你拼错了__init__ Also I'd recommend using new style inheritance. 另外我建议使用新的样式继承。

class ClientThread(threading.Thread):

    def __init__(self, ip, port, socket):
        super(ClientThread, self).__init__()
        self.ip = ip
        self.port = port
        self.socket = socket
        print "New thread started for "+ip+":"+str(port)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM