Get stack trace from an existing unwinder with retry for transient errors. This handles the case where we want to reuse an existing RemoteUnwinder instance but still handle transient failures like "Failed to parse initial frame in chain" that can occur when sampling at an inopportune mo
(unwinder, timeout=SHORT_TIMEOUT, condition=None)
| 255 | |
| 256 | |
| 257 | def _get_stack_trace_with_retry(unwinder, timeout=SHORT_TIMEOUT, condition=None): |
| 258 | """Get stack trace from an existing unwinder with retry for transient errors. |
| 259 | |
| 260 | This handles the case where we want to reuse an existing RemoteUnwinder |
| 261 | instance but still handle transient failures like "Failed to parse initial |
| 262 | frame in chain" that can occur when sampling at an inopportune moment. |
| 263 | If condition is provided, keeps retrying until condition(traces) is True. |
| 264 | """ |
| 265 | last_error = None |
| 266 | for _ in busy_retry(timeout): |
| 267 | try: |
| 268 | traces = unwinder.get_stack_trace() |
| 269 | if condition is None or condition(traces): |
| 270 | return traces |
| 271 | # Condition not met yet, keep retrying |
| 272 | except TRANSIENT_ERRORS as e: |
| 273 | last_error = e |
| 274 | continue |
| 275 | if last_error: |
| 276 | raise RuntimeError( |
| 277 | f"Failed to get stack trace after retries: {last_error}" |
| 278 | ) |
| 279 | raise RuntimeError("Condition never satisfied within timeout") |
| 280 | |
| 281 | |
| 282 | # ============================================================================ |
no test coverage detected
searching dependent graphs…