2

I've the following subclass of SocketServer.TCPServer:

class MP3Server (SocketServer.TCPServer):

    def __init__(self, server_address, RequestHandlerClass, SoundObj, DocRoot):
        self.allow_reuse_address = True
        SocketServer.TCPServer.__init__(self,
                                        server_address,
                                        RequestHandlerClass)

Before initializing I'm setting self.allow_reuse_address to True. But, still, when I stop and restart my server, I get the error about the address which is already in use.

I've also tried to change that line into SocketServer.TCPServer.allow_reuse_address = True, but it doesn't work the same (and to be honest I didn't expect different with this second solution).

Zagorax
  • 11,440
  • 8
  • 44
  • 56
  • Try the two solutions in http://stackoverflow.com/questions/2274320 ? – Armin Rigo Oct 19 '13 at 16:07
  • @ArminRigo, I've seen them, but in there they are using the class as it is and they are not sub-classing it. I would like to create a subclass which has, by default, that parameter set. – Zagorax Oct 19 '13 at 18:01
  • First call the base class, then set the property. Most probably your `allow_reuse_address` is overwritten by the call to the SocketServer.TCPServer constructor. – mguijarr Oct 20 '13 at 04:17
  • @mguijarr, unfortunately not! That was my first guess and my first try. Nothing changes. – Zagorax Oct 20 '13 at 09:23

0 Answers0