[projects/pld-builder.new] request_handler: record a request id only once it is decided
arekm
arekm at pld-linux.org
Mon Oct 26 17:17:31 CET 2026
commit ac4539d4c711b01e4675a8accd3a7a3056171fd7
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Oct 24 14:50:21 2026 +0200
request_handler: record a request id only once it is decided
An id recorded before queueing made a retry after a failure look like a
duplicate, and the request was lost. Refusals record it after mailing.
An accepted request records it only once it holds the queue lock, and
takes it back when writing the id or the queue fails.
PLD_Builder/request_handler.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index 314ce71..bda4e48 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -1,5 +1,6 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+import os
import time
import sys
from http import HTTPStatus
@@ -29,10 +30,6 @@ def check_double_id(id):
return 1
ids.close()
- ids = open(path.processed_ids_file, "a")
- ids.write(id_nl)
- ids.close()
-
return 0
def handle_group(r, user):
@@ -48,12 +45,13 @@ def handle_group(r, user):
m.set_headers(subject = "building %s failed" % spec)
m.write_line(msg)
m.send()
+ util.append_to(path.processed_ids_file, r.id)
lockf.close()
return status
lockf = lock("request")
if check_double_id(r.id):
- # resent after it was queued
+ # already decided: queued before, or refused and mailed then
lockf.close()
return HTTPStatus.OK
@@ -126,7 +124,15 @@ def handle_group(r, user):
q.lock(0)
q.read()
q.add(r)
- q.write()
+ # the id is taken back when writing it or the queue fails: a retry is
+ # never queued twice, and a request that failed on the way can be resent
+ ids_size = os.path.getsize(path.processed_ids_file)
+ try:
+ util.append_to(path.processed_ids_file, r.id)
+ q.write()
+ except BaseException:
+ os.truncate(path.processed_ids_file, ids_size)
+ raise
q.unlock()
lockf.close()
return HTTPStatus.OK
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d
More information about the pld-cvs-commit
mailing list