10000 Overhaul eager task factory design · python/cpython@6f2a47a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f2a47a

Browse files
itamarojbower-fb
andcommitted
Overhaul eager task factory design
Always create a task object to resolve the design flaw with structured concurrency. Push the eager step execution into the task implementation, so the task itself knows to eagerly execute the first step if created via the eager task factory. Co-authored-by: Jacob Bower <jbower@meta.com>
1 parent 563ffd4 commit 6f2a47a

8 files changed

+548
-130
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ struct _Py_global_strings {
339339
STRUCT_FOR_ID(copy)
340340
STRUCT_FOR_ID(copyreg)
341341
STRUCT_FOR_ID(coro)
342-
STRUCT_FOR_ID(coro_result)
343342
STRUCT_FOR_ID(count)
344343
STRUCT_FOR_ID(cwd)
345344
STRUCT_FOR_ID(d)
@@ -371,6 +370,7 @@ struct _Py_global_strings {
371370
STRUCT_FOR_ID(dst_dir_fd)
372371
STRUCT_FOR_ID(duration)
373372
STRUCT_FOR_ID(e)
373+
STRUCT_FOR_ID(eager_start)
374374
STRUCT_FOR_ID(effective_ids)
375375
STRUCT_FOR_ID(element_factory)
376376
STRUCT_FOR_ID(encode)
@@ -460,6 +460,7 @@ struct _Py_global_strings {
460460
STRUCT_FOR_ID(instructions)
461461
STRUCT_FOR_ID(intern)
462462
STRUCT_FOR_ID(intersection)
463+
STRUCT_FOR_ID(is_running)
463464
STRUCT_FOR_ID(isatty)
464465
STRUCT_FOR_ID(isinstance)
465466
STRUCT_FOR_ID(isoformat)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/asyncio/taskgroups.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def create_task(self, coro, *, name=None, context=None):
163163
task = self._loop.create_task(coro)
164164
else:
165165
task = self._loop.create_task(coro, context=context)
166-
if name is not None and not task.done(): # If it's done already, it's a future
167-
tasks._set_task_name(task, name)
166+
tasks._set_task_name(task, name)
168167
task.add_done_callback(self._on_task_done)
169168
self._tasks.add(task)
170169
return task

0 commit comments

Comments
 (0)
0