Closed jchayat closed 6 years ago
Interesting. Will investigate.
I've pushed a change that fixes the above example and which might work generally. Probably needs more testing. Would like to get feedback if it solves the problem.
Yes, my tests pass now. 👍
Closing as earlier fix seems to have addressed it.
Symptom
When running the following code (python 3.6.3, curio 0.8):
I'm getting:
Analysis
The problem seems to be that
task_group
is marked closed as soon as execution inlevel1
reaches theasync with
block end, which doesn't take into account that tasks under thetask_group
may continue spawning additional tasks undertask_group
.Why pass a TaskGroup to a spawned task?
Because otherwise it's impossible to return a value and have tasks keep running in the background. Consider the following code (which also fails):
Right now I'm working around this by suppling the queue from outside as a parameter - but this is ugly IMO.