bpo-46771: Implement task cancel requests counter (GH-31513)

This changes cancelling() and uncancel() to return the count of pending cancellations.

This can be used to avoid bugs in certain edge cases (e.g. two timeouts going off at the same time).
3 files changed