Feature request: USBContext.handleEventsCompleted()
It seems like, looking at the libusb async API docs, this function is the best way to solve the problem of "handle events only until a specific transfer is done." However, it doesn't currently exist in python-libusb1 and is marked as TODO. I'd love it if you could add this function, especially if it could get a Python wrapper that allows waiting for a list of transfers to complete.
It seems like, looking at the libusb async API docs, this function is the best way to solve the problem of "handle events only until a specific transfer is done."
This would be "Multi-threaded applications and asynchronous I/O", and especially the "libusb_handle_events() from multiple threads" section.
Would it make sense to have a USB event handling thread which would just call handleEvents in a loop, and, instead of calling an event handler function in the code waiting for a specific transfer to complete, wait on a mutex
which would get set in the completion callback ?
That would be pretty cool, especially if it could provide some sort of "wait for this list of USBTransfers to complete" functionality
Sorry, I was unclear: what I was suggesting is something which can be done outsite of python-libusb1, in your implementation of the transfer callback. I would rather keep as much of threading, locking and global tracking outside of python-libusb1 as possible.