From 93746b75a135a26d356540abb8fb18bbc2f2bb8f Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 11 Feb 2023 17:20:08 +0000 Subject: [PATCH] edit --- docs/blog/posts/create-task-psa.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/blog/posts/create-task-psa.md b/docs/blog/posts/create-task-psa.md index a3a7eb772..2422fe8ed 100644 --- a/docs/blog/posts/create-task-psa.md +++ b/docs/blog/posts/create-task-psa.md @@ -15,7 +15,9 @@ I'm taking a brief break from blogging about [Textual](https://github.com/Textua If you have ever used `asyncio.create_task` you may have created a bug for yourself that is challenging (read *almost impossible*) to reproduce. If it occurs, your code will likely fail in unpredictable ways. -The root cause of this [Heisenbug](Heisenbug) is that if you don't hold a reference to the task object returned by `create_task` then the task may simply disappear, without warning, when Python runs garbage collection. This behavior is [well documented](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task), as you can see from this excerpt (emphasis mine): +The root cause of this [Heisenbug](Heisenbug) is that if you don't hold a reference to the task object returned by `create_task` then the task may disappear without warning, when Python runs garbage collection. In other words the code in your task will stop running with no obvious indication why. + +This behavior is [well documented](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task), as you can see from this excerpt (emphasis mine): ![create task](../images/async-create-task.jpeg)