title: PyUSB: detect device unplug
body: <p>I want my program to exit, whenever the device gets unplugged. 
  My code:</p>
  
  <pre><code>device = usb.core.find(idVendor, idProduct)
  
  device.detach_kernel_driver(0)
  
  usb.util.claim_interface(device, 0)   
  usb_cfg = device.get_active_configuration()
  usb_interface = usb_cfg[(0,0)]
  port_in = usb_interface[0]
  port_out = usb_interface[1]
  
  while True:
      # do read ....
  </code></pre>
  
  <p>How can I detect an unplug of the device. </p>