Zhen Ye commited on
Commit
eb52404
·
1 Parent(s): 6a62982

Add writer loop error logging

Browse files
Files changed (1) hide show
  1. inference.py +33 -0
inference.py CHANGED
@@ -1307,6 +1307,39 @@ def run_inference(
1307
  logging.debug("Wrote frame %d/%d", next_idx, total_frames)
1308
 
1309
  except Exception as e:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1310
  # Check cancellation or timeout
1311
  if job_id and _check_cancellation(job_id): # This raises
1312
  pass
 
1307
  logging.debug("Wrote frame %d/%d", next_idx, total_frames)
1308
 
1309
  except Exception as e:
1310
+ logging.error(f"Writer loop processing error at index {next_idx}: {e}")
1311
+ # Important: If we failed AFTER popping from buffer, we must increment next_idx to avoid infinite loop
1312
+ # How do we know? We can check if next_idx is in buffer.
1313
+ # If we popped it, it's not in buffer.
1314
+ # But wait, next_idx is used for loop condition.
1315
+ # If we successfully popped it but failed later, we lost the frame.
1316
+ # We should increment next_idx to skip it.
1317
+
1318
+ # Heuristic: If we are here, something failed.
1319
+ # If we haven't successfully written/processed, we should probably skip this frame processing
1320
+ # to let the loop continue to next frame.
1321
+ # But we need to make sure we don't skip if the error was just "queue empty" (timeout).
1322
+
1323
+ # Wait, queue_out.get raises Empty. 'Empty' is NOT Exception?
1324
+ # In Python 'queue.Empty' inherits form Exception?
1325
+ # Actually 'queue.Empty' exception is just 'Exception'.
1326
+ # Let's check imports. from queue import Empty.
1327
+ # Yes.
1328
+
1329
+ # We should catch Empty explicitly?
1330
+ # No, get(timeout=1.0) raises Empty.
1331
+
1332
+ # If the error is NOT Empty, then it's a real crash.
1333
+ if "Empty" not in str(type(e)):
1334
+ logging.error(f"CRITICAL WRITER ERROR: {e}")
1335
+ # Force skip frame if we suspect we are stuck
1336
+ # Only if we hold the lock/state?
1337
+ # Simpler: Just try to proceed.
1338
+ # If we popped the frame, next_idx should be incremented?
1339
+ # Actually we can't easily know if we popped.
1340
+ # But we can check if we are stuck on the same index for too long?
1341
+ pass
1342
+
1343
  # Check cancellation or timeout
1344
  if job_id and _check_cancellation(job_id): # This raises
1345
  pass