Fix intermittent python crash on write timeout
Fix intermittent python crash on write timeout

If send_output_report is called and the remote device takes longer than
10 seconds to read the out endpoint, then the current transfer will
time out and return.  The current write will still be active, but the
buffers used by it will have been freed.  This memory corruption can
cause python to crash.

This patch fixes the problem by canceling the operation if it times
out.  It also adds additional checking to the write operation, which
allows send_output_report to return immediately if a failure occurs,
rather than waiting for a 10 second timeout.

The python crash on write can be reproduce prior to this patch by
constantly writing packets to the out endpoint, while the HID
device stops processing out packets for at least 10 seconds.

rene-aguirre/pywinusb,c1728p9/pywinusb