Skip to content

gh-128340: make asyncio.events.Handle.cancel() atomic#128347

Draft
graingert wants to merge 5 commits into
python:mainfrom
graingert:atomic-asyncio-handle-cancel
Draft

gh-128340: make asyncio.events.Handle.cancel() atomic#128347
graingert wants to merge 5 commits into
python:mainfrom
graingert:atomic-asyncio-handle-cancel

Conversation

@graingert

@graingert graingert commented Dec 30, 2024

Copy link
Copy Markdown
Contributor

Comment thread Lib/asyncio/events.py Outdated
Comment on lines +105 to +121
@property
def _cancelled(self):
return self.cancelled()

@property
def _callback(self):
callback_args = self._callback_args
if callback_args is _HANDLE_CANCELLED:
return None
return callback_args[0]

@property
def _args(self):
callback_args = self._callback_args
if callback_args is _HANDLE_CANCELLED:
return None
return callback_args[1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests access private attributes - I'd rather update those tests. These properties were just to get a PR up and passing CI quickly.

Comment thread Misc/NEWS.d/next/Library/2024-12-30-11-38-12.gh-issue-128340.uyqrdQ.rst Outdated
for i in range(ntodo):
handle = self._ready.popleft()
if handle._cancelled:
if handle.cancelled():

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant because _run checks now

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant