Returns this thread's context. If this thread does not yet have a context, returns a new context and sets this thread's context. New contexts are copies of DefaultContext.
()
| 354 | ) |
| 355 | |
| 356 | def getcontext(): |
| 357 | """Returns this thread's context. |
| 358 | |
| 359 | If this thread does not yet have a context, returns |
| 360 | a new context and sets this thread's context. |
| 361 | New contexts are copies of DefaultContext. |
| 362 | """ |
| 363 | try: |
| 364 | return _current_context_var.get() |
| 365 | except LookupError: |
| 366 | context = Context() |
| 367 | _current_context_var.set(context) |
| 368 | return context |
| 369 | |
| 370 | def setcontext(context): |
| 371 | """Set this thread's context to context.""" |
searching dependent graphs…