0

I want to use the cmd Python library, which provides an interactive shell to the tcp server, but it does not work properly. The application will have more than one infinite loop one for the server called serve_forever and one for the shell called cmdloop. The code looks like this:

class MyServer(TCPServer, Cmd):
    def __init__(self, host, port)
        TCPServer.__init__(self, (host, port), RequestHandler)

app = MyServer()
app.cmdloop()
app.serve_forever()

This also results in an error:

    if self.use_rawinput and self.completekey:
AttributeError: 'MyServer' object has no attribute 'completekey'. Did you mean: 'complete'?

I also tried out cmd2 and it too returns an error

ine 5262, in cmdloop
    self.terminal_lock.acquire()
AttributeError: 'Server' object has no attribute 'terminal_lock'

loaded_dypper
  • 262
  • 3
  • 12
  • 1
    I was getting the terminal lock error at some point because I missed a super().__init__() line inside your class __init__(). This line calls the __init__() of the inherited classes. https://realpython.com/python-super/#an-overview-of-pythons-super-function – Gabriel Sanchez May 19 '23 at 12:52

0 Answers0