Skip to content

Commit 8057cac

Browse files
add re-entrancy guard
1 parent 02c0a67 commit 8057cac

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ def _flush(*args: "Any", **kwargs: "Any") -> "Any":
323323

324324
def flush() -> None:
325325
nonlocal drained_count
326+
# Re-entrancy guard: if this `flush()`` is invoked from within an
327+
# in-progress drain (e.g. a custom transport), waiting on the background flusher
328+
# would deadlock, because the flusher is blocked inside our own handler.
329+
if getattr(getattr(batcher, "_active", None), "flag", False):
330+
orig_flush()
331+
return
332+
326333
# If the background flusher thread was never started (no spans have
327334
# been added), there is no thread to drain and the counter will never
328335
# advance. Fall back to the original synchronous flush.

0 commit comments

Comments
 (0)