Skip to content

Fix a potential memory leak in taskgroup#2068

Merged
1st1 merged 3 commits intogeldata:masterfrom
achimnol:feature/fix-memory-leak-taskgroup
Jan 5, 2021
Merged

Fix a potential memory leak in taskgroup#2068
1st1 merged 3 commits intogeldata:masterfrom
achimnol:feature/fix-memory-leak-taskgroup

Conversation

@achimnol
Copy link
Copy Markdown
Contributor

refs geldata/gel-python#140

  • This change does not affect the existing behavior of short-lived
    task groups, but will improve memory usage of long-lived task groups
    when there are many tasks spawned repeatedly for a long time.

  • In aiotools, the test case uses a virtual clock that makes
    asyncio.sleep to deterministically complete instantly, but here
    it seems not to have such thing. I've reduced the number of
    repetitions and time scale, but not sure it's stable or not.

* This change does not affect the existing behavior of short-lived
  task groups, but will improve memory usage of long-lived task groups
  when there are many tasks spawned repeatedly for a long time.

* In aiotools, the test case uses a virtual clock that makes
  asyncio.sleep to deterministically complete instantly, but here
  it seems not to have such thing.  I've reduced the number of
  repetitions and time scale, but not sure it's stable or not.
Copy link
Copy Markdown
Member

@1st1 1st1 left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks for the contribution!

@1st1 1st1 merged commit 35d3a20 into geldata:master Jan 5, 2021
fantix added a commit to fantix/edgedb that referenced this pull request May 27, 2022
https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
We usually use `TaskGroup.create_task()` with the assumption that the
enclosing `async with` block will wait untill all inner tasks complete,
without storing the references of the inner tasks, which can be GC-ed.

Partially reverted geldata#2068
fantix added a commit that referenced this pull request May 27, 2022
https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
We usually use `TaskGroup.create_task()` with the assumption that the
enclosing `async with` block will wait untill all inner tasks complete,
without storing the references of the inner tasks, which can be GC-ed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants