Created
October 1, 2021 16:13
-
-
Save gmarkall/9499105d736edf45a75c3197adc1d343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Works in conjunction with https://github.com/numba/numba/pull/7453 | |
from numba import cuda | |
import asyncio | |
async def f(): | |
s1 = cuda.stream() | |
s2 = cuda.stream() | |
f1 = s1.async_done() | |
f2 = s2.async_done() | |
futures_pending = True | |
pending = set((f1, f2)) | |
while futures_pending: | |
print("Iterating") | |
done, pending = await asyncio.wait(pending, | |
return_when=asyncio.FIRST_COMPLETED) | |
for d in done: | |
print(f"Stream {d.result()} done") | |
futures_pending = bool(pending) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(f()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment