---
title: thunder.core.trace.get_tracectx
description: >-
  Gets the current trace context, returning None if there is no current trace
  context.
canonical: >-
  https://lightning.ai/docs/thunder/stable/api-reference/generated/thunder.core.trace.get_tracectx
---
# thunder.core.trace.get_tracectx {#thunder-core-trace-get-tracectx}

### `thunder.core.trace.get_tracectx()` {#thunder.core.trace.get_tracectx}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/core/trace.py#L545-L554)

Gets the current trace context, returning None if there is no current trace context.

Return type:

[`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`TraceCtx`](/docs/thunder/0.2.6/api-reference/generated/thunder.core.trace.TraceCtx.md#thunder.core.trace.TraceCtx "thunder.core.trace.TraceCtx")\]

---

**Navigation**

- Parent: [Generated](/docs/thunder/0.2.6/api-reference/generated.md)
