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.
()
| 446 | ) |
| 447 | |
| 448 | def getcontext(): |
| 449 | """Returns this thread's context. |
| 450 | |
| 451 | If this thread does not yet have a context, returns |
| 452 | a new context and sets this thread's context. |
| 453 | New contexts are copies of DefaultContext. |
| 454 | """ |
| 455 | try: |
| 456 | return _current_context_var.get() |
| 457 | except LookupError: |
| 458 | context = Context() |
| 459 | _current_context_var.set(context) |
| 460 | return context |
| 461 | |
| 462 | def setcontext(context): |
| 463 | """Set this thread's context to context.""" |
no test coverage detected