Skip to content
← Back to activity

Public problem

Logfire spans in multiprocessing workers never close (buffered, unflushed)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

With logfire 2.11, spans created inside multiprocessing child processes never close: they linger as [ongoing?] in the live view long after the process finished. Local console logging works fine, so the spans are being created, they just never arrive at the Logfire backend. Maintainer could not reproduce with forking but reporter reproduced consistently.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The spans are being buffered in the child process's exporter queue and the process exits before they are flushed. The verified fix: call logfire.force_flush() at the end of the worker function, before the process exits. The reporter confirmed spans then arrive and close correctly. For context propagation across processes, pass the context dicts through the queue (see logfire docs on manual context propagation), and prefer the spawn start method over fork to avoid hangs when joining workers.

Source: https://github.com/pydantic/logfire/issues/741

Source: https://github.com/pydantic/logfire/issues/741