Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: USBContext.handleEventsCompleted() #94

Open
multiplemonomials opened this issue Jan 21, 2024 · 3 comments
Open

Feature request: USBContext.handleEventsCompleted() #94

multiplemonomials opened this issue Jan 21, 2024 · 3 comments

Comments

@multiplemonomials
Copy link
Contributor

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.

@multiplemonomials multiplemonomials changed the title Feature request USBContext.handleEventsCompleted() Feature request: USBContext.handleEventsCompleted() Jan 21, 2024
@vpelletier
Copy link
Owner

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 ?

@multiplemonomials
Copy link
Contributor Author

That would be pretty cool, especially if it could provide some sort of "wait for this list of USBTransfers to complete" functionality

@vpelletier
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants