Skip to content

async Task cancellation #88

@maxfischer2781

Description

@maxfischer2781

Short description of the feature
Cancelling a task currently a) allows the task to delay/ignore the cancellation and b) does not wait for completion. This means the cancelling task has to manually account for shutdown (e.g. MatterMiners/lapis#80).

Instead, we should offer an API that cancels a task and waits for completion. Notably, our internal, non-async API (Task.__close__) relies on prompt and successful termination.

Describe the solution you'd like
A public, asynchronous method for immediate shutdown. Roughly equivalent to:

class Task:
    ...

    async def terminate(self):
        self.__cancel__()
        await self.done

I'm still not 100% sure if we should use Coroutine.close(via .__close__) or add a cancellation (like .cancel currently does). close has guaranteed semantics, but allows no async action by the Task. A cancellation may be easier to handle in the activity, but requires a check for promptness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIthe way people interact with the frameworkenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions