pyodide icon indicating copy to clipboard operation
pyodide copied to clipboard

webloop should support cancellation

Open hoodmane opened this issue 1 year ago • 2 comments

To-do: example of it not supporting cancellation here. Cc @CNSeniorious000

hoodmane avatar May 26 '24 12:05 hoodmane

I am trying to abort ongoing fetches when micropip fails to resolve a dependency, so I want to cancel other running futures when one future ends up with an exception, so I wrote this:

    for future in futures:
        if not future.done():
            future.cancel()

But I still got several asyncio.exceptions.InvalidStateError: invalid state exception in stderr. I think since I've ensure that future is not done, cancel it shouldn't raises any exception.

However, I am still investigating this, not sure whether this is a bug of pyodide.webloop because I seldom use .cancel() on futures before. Not experienced in this field.

CNSeniorious000 avatar May 26 '24 12:05 CNSeniorious000

I strongly believe that it's a bug in webloop.

hoodmane avatar May 26 '24 14:05 hoodmane