From e1a8b2f236c577aebac8060ada97728e908656dc Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Mon, 9 Feb 2026 15:24:15 -0500 Subject: [PATCH] Yield GIL in discovery ring computation to unblock uwsgi during reforge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- make_post_sell/models/shop.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make_post_sell/models/shop.py b/make_post_sell/models/shop.py index ef0dc6a..69437a0 100644 --- a/make_post_sell/models/shop.py +++ b/make_post_sell/models/shop.py @@ -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