5 ms·
He doesn’t really get into what makes this a Heisenbug, only that it’s indeterminate in nature. Would attaching a debugger/stepping through the code make it les
by bandyaboot 4y ago
He doesn’t really get into what makes this a Heisenbug, only that it’s indeterminate in nature. Would attaching a debugger/stepping through the code make it less likely that your task would get garbage collected out from under you?
- foobarbecue 4y agoYeah, he seems to be re-defining the term to mean "a bug that occurs occasionally depending on system state" as opposed to "a bug that changes behavior when you observe it closely e.g. in a debugger."
- macintux 4y agoThe first is a common way of using the term Heisenbug. I first heard it used that way 10 years ago when discussing Erlang’s error handling model.
- foobarbecue 4y agoTIL. I guess I assumed it would hew more closely to the Uncertainty Principle. Edit: actually, come to think of it, I first heard of it in about 2006 from Jamie Brandon and at the time assumed it was something he'd made up. For a second there I forgot that 2006 is more than 10 years ago! (It was a python bug that went away when run in a debugger.)
- throwaway81523 4y agoCPython does most of its memory management by reference counting, which fails to reclaim circular structure. So to make sure it gets everything, it occasionally runs a conventional tracing GC. If the GC happens to run just after you create that async task, the task itself can get collected, it sounds like. It's good to know about this and is (my own editorializing) yet another reason Python3 should have used Erlang-style concurrency instead of this async stuff.
- Izkata 4y agoYou're probably going to need a reference to the task in order to inspect it in the debugger. Creating that reference prevents the bug.
- remram 4y agoIt's actually very not Heisenbug, because if you enable asyncio's debug mode [1], it will tell you what's going on. [1]: https://docs.python.org/3/library/asyncio-dev.html#debug-mode https://docs.python.org/3/library/asyncio-dev.html#debug-mod...