Opened 7 years ago

Last modified 6 years ago

#5058 enhancement new

cancellation for Deferreds returned by deferToThread

Reported by: Glyph Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

If you have a long queue of threaded work to do, threaded work may back up. If these Deferreds start timing out, and their work hasn't been scheduled yet, it would be great to remove it from the queue before it is attempted to be executed. If you .cancel() a Deferred returned by deferToThread, this should happen automatically.

This may also require some work on the reactor's side of things, but I have phrased this in terms of deferToThread already has an API which should already be doing this.

Change History (2)

comment:1 Changed 6 years ago by Doru Arfire

What if you try to .cancel() a Deferred that is being handled. Should an InProgress exception or something like that be raised?

comment:2 Changed 6 years ago by Jean-Paul Calderone

Deferred cancellation is a best effort thing. The goal of the cancellation API is to hide details of the cancellation from the caller. So no exception should be raised in that case. Instead, the result of the threaded operation should just be dropped when it becomes available.

Note: See TracTickets for help on using tickets.