Spaces:
Running
Running
Added timeout to pre_submit_lock in while-cycle
Browse files
app.py
CHANGED
@@ -530,7 +530,7 @@ def gradio_app():
|
|
530 |
pre_submission_btn.click(
|
531 |
fn=on_submit_pressed,
|
532 |
outputs=[pre_submission_btn],
|
533 |
-
).then(
|
534 |
fn=process_submission,
|
535 |
inputs=list(submission_inputs.values()),
|
536 |
outputs=[
|
@@ -541,6 +541,7 @@ def gradio_app():
|
|
541 |
pre_submit_info,
|
542 |
pre_submit_table,
|
543 |
],
|
|
|
544 |
)
|
545 |
|
546 |
submission_btn_yes.click(
|
|
|
530 |
pre_submission_btn.click(
|
531 |
fn=on_submit_pressed,
|
532 |
outputs=[pre_submission_btn],
|
533 |
+
).then(
|
534 |
fn=process_submission,
|
535 |
inputs=list(submission_inputs.values()),
|
536 |
outputs=[
|
|
|
541 |
pre_submit_info,
|
542 |
pre_submit_table,
|
543 |
],
|
544 |
+
concurrency_limit=None,
|
545 |
)
|
546 |
|
547 |
submission_btn_yes.click(
|
server.py
CHANGED
@@ -107,7 +107,27 @@ def check_significance(model_a_path, model_b_path):
|
|
107 |
result = check_significance_wait_for_result(result_url)
|
108 |
return result
|
109 |
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
class _ReadLock:
|
113 |
def __init__(self, lock):
|
@@ -312,8 +332,8 @@ class LeaderboardServer:
|
|
312 |
"""
|
313 |
|
314 |
while True:
|
315 |
-
with self.pre_submit_lock:
|
316 |
-
if self.pre_submit == None:
|
317 |
gr.Info('Checking integrity...', duration=15)
|
318 |
self.update_leaderboard()
|
319 |
|
@@ -703,8 +723,8 @@ class LeaderboardServer:
|
|
703 |
json.dump(data, f, separators=(',', ':')) # compact JSON
|
704 |
|
705 |
while True:
|
706 |
-
with self.pre_submit_lock:
|
707 |
-
if self.pre_submit == None:
|
708 |
gr.Info('Running tournament...', duration=15)
|
709 |
self.update_leaderboard()
|
710 |
if HF_FAKE_TOURNAMENT:
|
|
|
107 |
result = check_significance_wait_for_result(result_url)
|
108 |
return result
|
109 |
|
110 |
+
class TimeoutLock:
|
111 |
+
def __init__(self, lock=None, timeout=-1):
|
112 |
+
self.lock = lock or Lock()
|
113 |
+
self.timeout = timeout
|
114 |
+
self._lock_acquired = False
|
115 |
+
|
116 |
+
def __enter__(self):
|
117 |
+
acquired = self.lock.acquire(timeout=self.timeout)
|
118 |
+
if acquired:
|
119 |
+
self._lock_acquired = True
|
120 |
+
return acquired
|
121 |
+
|
122 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
123 |
+
if self._lock_acquired:
|
124 |
+
self.lock.release()
|
125 |
+
self._lock_acquired = False
|
126 |
+
|
127 |
+
def __call__(self, timeout):
|
128 |
+
return TimeoutLock(lock=self.lock, timeout=timeout)
|
129 |
+
|
130 |
+
pre_submit_lock = TimeoutLock()
|
131 |
|
132 |
class _ReadLock:
|
133 |
def __init__(self, lock):
|
|
|
332 |
"""
|
333 |
|
334 |
while True:
|
335 |
+
with self.pre_submit_lock(timeout=5) as acquired:
|
336 |
+
if acquired and self.pre_submit == None:
|
337 |
gr.Info('Checking integrity...', duration=15)
|
338 |
self.update_leaderboard()
|
339 |
|
|
|
723 |
json.dump(data, f, separators=(',', ':')) # compact JSON
|
724 |
|
725 |
while True:
|
726 |
+
with self.pre_submit_lock(timeout=5) as acquired:
|
727 |
+
if acquired and self.pre_submit == None:
|
728 |
gr.Info('Running tournament...', duration=15)
|
729 |
self.update_leaderboard()
|
730 |
if HF_FAKE_TOURNAMENT:
|