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:
parent
3e6786155a
commit
e1a8b2f236
1 changed files with 3 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue