Charles Yao and Claude Opus 4.8
2b4df02305
fix(dify_builder): close SSE subscription even when the response is never iterated
...
progress_bus.subscribe() eagerly enters the pub/sub subscription (opening a
Redis connection + starting a listener thread) BEFORE the SSE generator
exists, so the subscribe completes before the Celery advance can publish.
But the only close() lived in the generator's finally -- which Python does
not run if the generator is never started. A streaming Response dropped
before its first frame (client aborted, or an after_request/teardown error)
therefore leaked the connection + thread until process restart.
stream_advance_frames now returns a small _ClosingFrameStream wrapper whose
close() closes the subscription directly (idempotent); the WSGI server calls
close() on the response iterable even on early disconnect, so cleanup fires
regardless of iteration. The inner generator keeps its own finally for the
iterated/disconnect paths, so this is strictly additive -- no happy-path
change. All seven call sites get it unchanged.
Adds a regression test (never-iterated stream -> close() -> subscription closed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
2026-09-03 08:48:23 +08:00
..
2026-08-25 05:39:41 +00:00
2026-08-18 04:30:17 +00:00
2026-08-21 00:52:39 +00:00
2026-09-03 08:48:23 +08:00
2026-08-11 07:39:01 +00:00
2026-09-01 03:46:03 +00:00
2026-08-31 13:31:50 +08:00
2026-08-31 09:30:52 +00:00
2026-08-11 07:39:01 +00:00
2026-08-07 09:21:13 +00:00
2026-08-28 02:26:41 +00:00
2026-08-27 02:41:43 +00:00
2026-08-13 17:50:05 +00:00
2026-08-15 00:56:09 +00:00
2026-08-21 11:55:25 +00:00
2024-08-26 13:43:57 +08:00
2026-08-27 08:51:05 +00:00
2026-08-27 08:51:05 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-25 01:48:12 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:46:06 +00:00
2026-08-21 08:05:43 +00:00
2026-08-25 01:48:12 +00:00
2026-08-31 03:22:01 +00:00
2026-08-31 03:22:01 +00:00
2026-08-26 07:14:27 +00:00
2026-08-31 03:22:01 +00:00
2026-08-21 08:05:43 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-31 03:22:01 +00:00
2026-08-20 05:03:08 +00:00
2026-08-31 03:22:01 +00:00
2026-07-08 03:07:27 +00:00
2026-08-20 18:59:44 +00:00
2026-08-24 05:29:14 +00:00
2026-08-25 10:21:32 +00:00
2026-07-24 11:35:12 +00:00
2026-07-08 03:07:27 +00:00
2026-08-29 07:04:18 +00:00
2026-07-08 03:07:27 +00:00
2026-06-08 04:53:12 +00:00
2026-08-20 05:05:31 +00:00
2026-08-21 00:52:39 +00:00
2026-08-31 09:30:52 +00:00
2026-07-15 06:48:28 +00:00
2026-07-15 09:31:09 +00:00
2026-08-28 08:50:30 +00:00
2026-08-26 06:31:06 +00:00
2026-08-11 07:39:01 +00:00
2026-06-18 00:18:03 +00:00
2026-08-25 10:21:32 +00:00
2026-08-24 01:55:48 +00:00
2026-08-26 06:32:13 +00:00
2026-08-11 07:39:01 +00:00
2025-09-06 03:32:23 +08:00
2026-08-26 06:32:13 +00:00
2026-08-25 10:21:32 +00:00
2026-07-08 03:07:27 +00:00
2026-08-25 10:21:32 +00:00
2026-08-26 07:33:37 +00:00
2026-07-15 09:31:09 +00:00
2026-08-29 07:04:18 +00:00
2026-08-17 02:41:26 +00:00
2026-07-07 02:06:49 +00:00
2026-08-19 06:57:47 +00:00
2026-06-19 01:02:01 +00:00
2026-08-19 10:34:37 +00:00
2026-08-06 08:27:37 +00:00
2026-08-24 06:35:42 +00:00
2026-08-24 06:35:42 +00:00
2026-08-26 17:15:19 +08:00
2026-08-10 03:27:56 +00:00
2026-08-04 13:14:02 +00:00
2026-08-20 05:05:31 +00:00
2026-07-15 06:48:28 +00:00
2026-06-18 00:18:03 +00:00
2026-07-15 06:48:28 +00:00
2026-07-03 03:45:21 +00:00
2026-08-12 08:42:09 +00:00
2026-07-29 09:51:34 +00:00
2026-07-24 07:11:48 +00:00
2026-07-23 01:48:36 +00:00
2026-07-02 17:00:47 +00:00
2026-08-03 02:24:18 +00:00
2026-08-25 10:21:32 +00:00
2026-08-11 16:37:14 +00:00
2026-08-07 00:42:13 +00:00
2026-08-11 07:39:01 +00:00
2026-08-31 04:37:07 +00:00
2026-08-31 04:37:07 +00:00
2026-08-26 07:33:37 +00:00
2026-07-08 03:07:27 +00:00
2026-08-26 07:33:37 +00:00
2026-06-22 06:45:03 +00:00
2026-07-08 03:07:27 +00:00
2026-08-24 01:55:48 +00:00
2026-08-15 00:56:09 +00:00
2026-08-20 13:13:43 +00:00
2026-08-20 13:13:43 +00:00
2026-07-08 03:07:27 +00:00
2026-08-08 11:52:15 +00:00
2026-08-24 01:57:17 +00:00
2026-08-08 11:52:15 +00:00
2026-08-26 07:02:45 +00:00
2026-08-20 08:52:45 +00:00
2026-07-15 06:48:28 +00:00
2026-08-20 07:48:02 +00:00
2026-08-31 04:37:07 +00:00
2026-08-25 10:21:32 +00:00
2026-08-24 05:29:14 +00:00
2026-08-24 05:29:14 +00:00
2026-08-11 07:39:01 +00:00
2026-08-20 13:13:42 +00:00
2026-08-19 06:57:47 +00:00
2026-07-27 02:12:57 +00:00
2026-08-25 10:21:32 +00:00
2026-08-11 07:39:01 +00:00
2026-08-20 05:05:31 +00:00
2026-07-08 03:07:27 +00:00
2026-08-20 02:27:49 +00:00
2026-08-21 08:13:23 +00:00
2026-08-02 02:49:17 +00:00
2026-08-28 14:32:27 +00:00
2026-08-21 00:52:39 +00:00
2026-04-16 02:21:04 +00:00
2026-07-21 02:07:47 +00:00
2026-08-03 02:24:18 +00:00
2026-08-25 10:21:32 +00:00
2026-07-15 05:58:37 +00:00
2026-06-30 08:19:58 +00:00
2026-07-15 06:48:28 +00:00
2026-08-25 05:39:41 +00:00
2026-08-27 02:41:02 +00:00
2026-08-12 01:55:36 +00:00
2026-08-06 01:08:39 +00:00
2026-08-06 01:08:39 +00:00
2026-08-11 07:39:01 +00:00
2026-08-11 07:39:01 +00:00
2026-08-12 07:45:39 +00:00