Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit b8cddac

Browse files
author
Anselm Kruis
committed
Stackless issue #199: stackless call "asyncio._CTask"
Remove an unused static function, add test cases and change-log.
1 parent 338e412 commit b8cddac

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Modules/_asynciomodule.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,21 +2542,17 @@ static PyStacklessFunctionDeclarationObject task_step_impl_declaration = {
25422542
task_step_impl_stackless,
25432543
"task_step_impl_stackless"
25442544
};
2545-
#endif
25462545

25472546
static PyObject *
2548-
task_step_impl(TaskObj *task, PyObject *exc)
2547+
task_step_impl_part1(TaskObj *task, PyObject *exc, int *failed)
25492548
{
2550-
#ifdef STACKLESS
2551-
return PyStackless_CallFunction(&task_step_impl_declaration, Py_None,
2552-
(PyObject *)task, exc, NULL, 0, NULL);
2553-
}
2549+
STACKLESS_GETARG();
2550+
#else /* #ifdef STACKLESS */
25542551

25552552
static PyObject *
2556-
task_step_impl_part1(TaskObj *task, PyObject *exc, int *failed)
2553+
task_step_impl(TaskObj *task, PyObject *exc)
25572554
{
2558-
#endif
2559-
STACKLESS_GETARG();
2555+
#endif /* #ifdef STACKLESS */
25602556
int res;
25612557
int clear_exc = 0;
25622558
PyObject *result = NULL;

Stackless/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://github.com/stackless-dev/stackless/issues/199
13+
Enable stackless calls of coroutines wrapped in "asyncio._CTask", if
14+
soft-switching is enabled. Now asyncio runs coroutines stackless.
15+
1216
- https://github.com/stackless-dev/stackless/issues/197
1317
Enable stackless calls of method "contextvars.Context.run", if soft-switching
1418
is enabled.

Stackless/unittests/test_generator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ async def test():
366366
def test_context_run(self):
367367
contextvars.Context().run(self.assertLevel)
368368

369-
# needs Stackless pull request #188
370-
def xx_test_asyncio(self):
369+
def _test_asyncio(self, task_class):
371370
async def test():
372371
try:
373372
await self.coro()
@@ -377,13 +376,19 @@ async def test():
377376
asyncio.set_event_loop(asyncio.new_event_loop())
378377
self.addCleanup(asyncio.set_event_loop, None)
379378
loop = asyncio.get_event_loop()
380-
task = asyncio.tasks._PyTask(test())
379+
task = task_class(test())
381380
asyncio.ensure_future(task)
382381
try:
383382
loop.run_forever()
384383
finally:
385384
loop.close()
386385

386+
def test_asyncio_PyTask(self):
387+
self._test_asyncio(asyncio.tasks._PyTask)
388+
389+
def test_asyncio_CTask(self):
390+
self._test_asyncio(asyncio.tasks._CTask)
391+
387392

388393
if __name__ == '__main__':
389394
unittest.main()

0 commit comments

Comments
 (0)