-1

Ok I have looked at similar questions but it didn't seem to help mine, but everyone's code is different and I am also a beginner at Python coding. Can someone help me figure this out so I can know how to deal with this next time it pops up?

        def run(self):
               while True:
                      c, a = self.sock.accept()
                      cThread = threading.Thread(target=self.handler, args=(c,a))
                      cThread.daemon = True
                      cThread.start()
                      self.connections.append(c)
                      print(self.connections)

The error I get point to: def run(self): exactly how it prints in the terminal.

edit: I have changed the screwed up part of the code as I didn't notice it till people pointed it out. Now it looks as it does in my laptop. But the problem still persists.

1 Answers1

0

There is an additional amount of indentation in your code. By default the indentation level is 2/4 in python. To get your code working, reduce the indentation level. There is also an error in your code, You missed a ). BTW, It is always better to include the error you have received in your question.

def run(self):
    while True:
        c, a = self.sock.accept()
        cThread = threading.Thread(target=self.handler, args=(c,a)
        cThread.daemon = True
        cThread.start()
        self.connections.append(c)
        print(self.connections)
  • I have done all of that and it still is giving me the same error on that piece of code. This is semi frustrating lol – Dave Mills Jul 01 '19 at 01:43