title: Interrupting a bluetooth connection in a programmable way
body: <p>I am wanting to interrupt this bluetooth connect in a programmable way in python if I can. I have read many articles online and cannot seem to find a way to send an interrupt, other than a keyboard interrupt, to the <code>client_sock, clientInfo = server_sock.accept()</code> so that this line of code stops its bluetooth connectivity. The end game is to use my GUI side of this program by implementing a &quot;Stop Connection&quot; button in my GUI to halt the bluetooth connection.  Is there a way to do that in python3 at all, or is this something that can only be handled via command line???</p>
  <pre><code> size = 1024
      while True:
          self.bluetooth_information.append(&quot;Waiting for connection&quot;)
          self.bluetooth_information.append(str(datetime.now().time()))
          client_sock, clientInfo = server_sock.accept()
          try:
              data = client_sock.recv(size)                        # receives data from client
              if len(data) == 0:
                  break
          
          client_sock.send(self.parse.process_data(data))      # Echo response back to client
  
      # except bluetooth.btcommon.BluetoothError:
      #    pass
      
          if self.stop:
              client_sock.close()
              server_sock.close()
              self.stop = False
              self.bluetooth_information.clear()
              break
  
      except KeyboardInterrupt:
          client_sock.close()
          server_sock.close()
          break
  </code></pre>