You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using ContextTask class currently creates empty context for each of the tasks. The desirable behavior would be that child tasks would have access to the parent task context.
Right now it seems its hard to implement the way that would solve it only by modifying the ContextTask code, however it can be solved by running task creation in the parent's context:
# Create a new task. Putting it on the ready queuedefnew_task(coro):
# Children should be created with parent context if anynonlocalcurrentifcurrentandcurrent._context:
task=current._context.run(taskcls, coro)
else:
task=taskcls(coro)
tasks[task.id] =taskreschedule_task(task)
forain_activations:
a.created(task)
returntask
The text was updated successfully, but these errors were encountered:
Just to make sure that I understand this, the primary issue is that new tasks aren't created within the context of the parent task?
All things equal, I don't want the Curio core to be dependent on contextvars. However, it may be possible to restructure things slightly to make this possible. I will investigate.
Yes, indeed, the issue that the new tasks are created outside current context, so those tasks cant access the parent context.
I endup using this patch which does not incluide too much dependancies in the core, but still there are probably better ways to do this. hansonrobotics@1c56eaf
Using ContextTask class currently creates empty context for each of the tasks. The desirable behavior would be that child tasks would have access to the parent task context.
Right now it seems its hard to implement the way that would solve it only by modifying the ContextTask code, however it can be solved by running task creation in the parent's context:
The text was updated successfully, but these errors were encountered: