Yield GIL in discovery ring computation to unblock uwsgi during reforge

The O(n²) greedy walk held the GIL for the entire computation, starving
uwsgi workers on the 2 vCPU box. time.sleep(0) in the inner loop
releases the GIL each iteration so request handling can interleave.
This commit is contained in:
russell@unturf.com 2026-02-09 15:24:15 -05:00
parent 3e6786155a
commit e1a8b2f236

View file

@ -1,6 +1,7 @@
import json
import logging
import threading
import time
import uuid
from sqlalchemy import Column, BigInteger, Boolean, Unicode, UnicodeText, func
@ -665,6 +666,8 @@ def compute_discovery_ring(shop):
score = len(accumulated_stems & p_stems) / len(union)
else:
score = 0
# Yield GIL so uwsgi workers can serve requests
time.sleep(0)
# Tiebreak: highest score, then newest, then ID
if (score > best_score or