Spaces:
Sleeping
Sleeping
Fix ASGI protocol violation with ZeroGPU generator functions
Browse filesAdded explicit return statements after final yields in generate_qr_code_unified
to prevent race condition during GPU release. This fixes the ASGI error that
only occurs on HuggingFace Spaces:
AssertionError: Unexpected message: {'type': 'http.response.start'...}
Changes:
- Standard pipeline with upscaling (line 2095)
- Standard pipeline without upscaling (line 2123)
- Artistic pipeline with upscaling (line 2523)
- Artistic pipeline without upscaling (line 2545)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -2092,6 +2092,7 @@ def _pipeline_standard(
|
|
| 2092 |
msg = f"No errors, all good! Final QR art generated and upscaled. (step {current_step}/{total_steps})"
|
| 2093 |
log_progress(msg, gr_progress, 1.0)
|
| 2094 |
yield (pil_image, msg)
|
|
|
|
| 2095 |
else:
|
| 2096 |
# No upscaling
|
| 2097 |
image_tensor = get_value_at_index(vaedecode_21, 0)
|
|
@@ -2119,6 +2120,7 @@ def _pipeline_standard(
|
|
| 2119 |
msg = f"No errors, all good! Final QR art generated. (step {current_step}/{total_steps})"
|
| 2120 |
log_progress(msg, gr_progress, 1.0)
|
| 2121 |
yield pil_image, msg
|
|
|
|
| 2122 |
|
| 2123 |
|
| 2124 |
def _pipeline_artistic(
|
|
@@ -2518,6 +2520,7 @@ def _pipeline_artistic(
|
|
| 2518 |
msg = f"No errors, all good! Final artistic QR code generated and upscaled. (step {current_step}/{total_steps})"
|
| 2519 |
log_progress(msg, gr_progress, 1.0)
|
| 2520 |
yield (final_image, msg)
|
|
|
|
| 2521 |
else:
|
| 2522 |
# No upscaling
|
| 2523 |
image_tensor = get_value_at_index(final_decoded, 0)
|
|
@@ -2539,6 +2542,7 @@ def _pipeline_artistic(
|
|
| 2539 |
msg = f"No errors, all good! Final artistic QR code generated. (step {current_step}/{total_steps})"
|
| 2540 |
log_progress(msg, gr_progress, 1.0)
|
| 2541 |
yield (final_image, msg)
|
|
|
|
| 2542 |
|
| 2543 |
|
| 2544 |
if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
|
|
| 2092 |
msg = f"No errors, all good! Final QR art generated and upscaled. (step {current_step}/{total_steps})"
|
| 2093 |
log_progress(msg, gr_progress, 1.0)
|
| 2094 |
yield (pil_image, msg)
|
| 2095 |
+
return # Explicit return to cleanly exit generator
|
| 2096 |
else:
|
| 2097 |
# No upscaling
|
| 2098 |
image_tensor = get_value_at_index(vaedecode_21, 0)
|
|
|
|
| 2120 |
msg = f"No errors, all good! Final QR art generated. (step {current_step}/{total_steps})"
|
| 2121 |
log_progress(msg, gr_progress, 1.0)
|
| 2122 |
yield pil_image, msg
|
| 2123 |
+
return # Explicit return to cleanly exit generator
|
| 2124 |
|
| 2125 |
|
| 2126 |
def _pipeline_artistic(
|
|
|
|
| 2520 |
msg = f"No errors, all good! Final artistic QR code generated and upscaled. (step {current_step}/{total_steps})"
|
| 2521 |
log_progress(msg, gr_progress, 1.0)
|
| 2522 |
yield (final_image, msg)
|
| 2523 |
+
return # Explicit return to cleanly exit generator
|
| 2524 |
else:
|
| 2525 |
# No upscaling
|
| 2526 |
image_tensor = get_value_at_index(final_decoded, 0)
|
|
|
|
| 2542 |
msg = f"No errors, all good! Final artistic QR code generated. (step {current_step}/{total_steps})"
|
| 2543 |
log_progress(msg, gr_progress, 1.0)
|
| 2544 |
yield (final_image, msg)
|
| 2545 |
+
return # Explicit return to cleanly exit generator
|
| 2546 |
|
| 2547 |
|
| 2548 |
if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|