When setting the result for a Future object with Future.set_result() for a cancelled future we get an InvalidStateError.
So I would suggest a small addition in the resolve() method:
def resolve(self, future, result=None):
if not future.cancelled():
future.set_result(result)
When setting the result for a Future object with Future.set_result() for a cancelled future we get an InvalidStateError.
So I would suggest a small addition in the resolve() method: