Skip to content

Commit d45f29e

Browse files
rossopsclaude
andcommitted
fix(watson): correct flush hook signature after bad merge
The merge back from master reintroduced master's class-based wrapper signature `(self, engine, obj)` on top of dev's instance-based patch of `search_context_manager.add_to_context`. Assigning to the instance means Python never binds `self`, so watson's post_save calls the wrapper with `(engine, obj)` and it blows up with "missing required positional argument: 'obj'". That killed the calculate_grade and post_process_findings_batch celery tasks whenever product grading was on, which cascaded into the perf test UnboundLocalErrors and zeroed-out query counts. Restore dev's `(engine, obj)` signature and drop the now-moot singleton guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7f7ec7d commit d45f29e

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

dojo/middleware.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,8 @@ def install_intermediate_flush_hook():
350350

351351
original_add = search_context_manager.add_to_context # bound method
352352

353-
def add_to_context_with_flush(self, engine, obj):
354-
original_add(self, engine, obj)
355-
# The intermediate flush is a request-path optimization on the global singleton
356-
# context (AsyncSearchContextMiddleware). The async reindex task
357-
# update_watson_search_index_for_model() builds its OWN SearchContextManager and
358-
# IS the drain target -- if it re-drained its batch it would dispatch a clone of
359-
# itself, discard those pks unindexed, and loop forever (queue ~0, worker pegged,
360-
# nothing indexed). Only the singleton intermediate-flushes; any ad-hoc context
361-
# manager indexes its own batch on end().
362-
if self is not search_context_manager:
363-
return
353+
def add_to_context_with_flush(engine, obj):
354+
original_add(engine, obj)
364355
threshold = getattr(settings, "WATSON_ASYNC_INDEX_UPDATE_BATCH_SIZE", 1000)
365356
if threshold <= 0 or not search_context_manager._stack:
366357
return

0 commit comments

Comments
 (0)