Someone wanted to learn this too, so Grasp built them a personal learning path.
You can keep exploring this one or create your own
Python Context Managers and ContextVars
Recommended resources
The freely available resources this course will direct you to.
Module 2
Understanding What a `with` Statement Calls
Module 3
Connecting One `yield` to One `with` Block
Module 4
Seeing Why Mutation Is Shared but Rebinding Is Not
Module 5