I'm having a problem when I connect to the server, it connects properly and the code in the thread runs perfectly, the problem is that it appears as if I'm not receiving any message, or at least self.data is not updating, I tried checking with print("") and it appears as if the while loop after I start the thread is not reached by the code. Here is my code:
class Client:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def __init__(self, address):
self.sock.connect((address, 10000))
self.playerID = PID
self.data = [0, 0, 0, 0, 0]
iThread = threading.Thread(target=self.game(self.data))
iThread.daemon = True
iThread.start()
while True:
data = self.sock.recv(2048)
datas = pickle.loads(data)
for i in range(0, len(self.data)):
self.data[i]= datas[i]
if not data:
break
def game(self, data):
morecode...
gamereturn anything?self.game(self.data)when you create theThread, rather than letting the thread call it.