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

Function to wait on multiple IOFutures #79

Open
jakirkham opened this issue Jun 2, 2022 · 2 comments
Open

Function to wait on multiple IOFutures #79

jakirkham opened this issue Jun 2, 2022 · 2 comments

Comments

@jakirkham
Copy link
Member

Currently one needs to perform each read/write and wait on them individually. Like so

future1 = f.pread(d[:50])
future2 = f.pread(d[50:], file_offset=d[:50].nbytes)
future1.get() # Wait for first read
future2.get() # Wait for second read

However one use case is to do a bunch of writes or reads asynchronously. For example ( zarr-developers/zarr-python#1040 ). Doing this would accumulate a list of IOFutures from each operation.

In this case it would be helpful to have an API that is able to wait on that whole list of operations to complete. Perhaps like concurrent.futures.wait.

@spec-benno
Copy link

Wouldn't it anyway be a good idea to use the build-in future concept of Python:
https://docs.python.org/3/library/concurrent.futures.html#future-objects

Or what might be even nicer, would be to use Queues from the asyncio library:
https://docs.python.org/3/library/asyncio.html

I'm experiencing the problem that I need to recover data from a FIFO buffer on the GPU and want to write it to a RAID system. I can only have a maximum number of pwrites() at the same time and I need to wait for a process to finish before freeing that FIFO memory part.

@madsbk
Copy link
Member

madsbk commented Jul 22, 2024

It is not easy to bind C++ futures with Python without excessive locking of Python’s GIL. However, ucxx manages to do this without too much performance overhead thus we should investigate this at some point.

For now, you might get a similar result by calling raw_write() from a Python thread, or maybe in a async function.

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

3 participants