Skip to content

Conversation

@kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Oct 13, 2025

When updating the currently running task for a python impmlemented task (_PyTask), also inform the C bookkeping code in _asyncio so that query functions such as current_task() work correcty.
This allows running Python-based tasks even if the _asyncio module is available.

  • Inform the _asyncio module when setting the current task, via the _enter_task(), leave_task and _swap_current_task() functions.
  • use _asyncio module as primary source of truth for current_task()
  • Similarly inform _asyncio module when setting current event loop and when querying it.

There are unit test cases, test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_new_process and test_asyncio.test_futures2.PyFutureTests that started failing when this PR was partially implemented, because they use _PyTask objects. They previously just happened to work because the tasks thus created were not making use of the current_task() api.

@kristjanvalur kristjanvalur marked this pull request as ready for review October 16, 2025 14:28
@kristjanvalur kristjanvalur marked this pull request as draft October 16, 2025 14:28
@kristjanvalur kristjanvalur marked this pull request as ready for review October 16, 2025 15:54
@kristjanvalur
Copy link
Contributor Author

The issue and fix have been rejected by the powers that be, so I am closing this. A fix for this issue, for those who celebrate, has been added to https://github.com/kristjanvalur/py-asynkit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant