Commit 203e66f1 authored by Marco Buttu's avatar Marco Buttu
Browse files

Fix #151: send two #stop commands to the server

parent 416cc908
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -56,8 +56,7 @@ class MSCU(object):
                connection.close()
                continue
            else:
                # From here on, this is the child. 
                self.socket.close() # Close the parent's socket
                # From now on, this is the child. 
                try:
                    buff = ''
                    while True:
@@ -77,7 +76,6 @@ class MSCU(object):
                        try:
                            if data.startswith('#stop'):
                                stop_server.value = True
                                connection.close()
                                break
                            elif data.startswith('#setpos_NAK'):
                                setpos_NAK[1].value = True  # The SRP address
@@ -132,7 +130,6 @@ class MSCU(object):
                except:
                    raise

                # Close the connection
                try:
                     connection.close()
                except KeyboardInterrupt:
@@ -140,9 +137,7 @@ class MSCU(object):
                except:
                    traceback.print_exc()

                # Done handling the connection. Child process *must* terminate
                # and not go back to the top of the loop
                sys.exit(0)
                sys.exit(0) # The child process *must* terminate

    def _welcome(self):
        print "*"*43
@@ -167,6 +162,8 @@ class MSCU(object):

    @staticmethod
    def stop(server=('127.0.0.1', 10000)):
        # The second stop is mandatory
        for i in range(2):
            sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sockobj.settimeout(2)
            sockobj.connect(server)