Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created October 1, 2021 16:13
Show Gist options
  • Save gmarkall/9499105d736edf45a75c3197adc1d343 to your computer and use it in GitHub Desktop.
Save gmarkall/9499105d736edf45a75c3197adc1d343 to your computer and use it in GitHub Desktop.
# 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