forum : requêtes traitées une par une sur la connexion SQLite partagée (publication coupée : « site inaccessible »)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
0cf0b78822
révision
6462b41b30
2 fichiers modifiés
+21
Aucun fichier ne correspond à votre recherche
@@ -11,6 +11,7 @@ Second serveur, sur la même base que le forum (python forum/panneau.py --port 8
|
|||||||
Variables d'environnement : celles du forum (FORUM_HUB_URL, FORUM_CLIENT_ID, FORUM_OAUTH_SECRET[_FILE],
|
Variables d'environnement : celles du forum (FORUM_HUB_URL, FORUM_CLIENT_ID, FORUM_OAUTH_SECRET[_FILE],
|
||||||
FORUM_PROPRIETAIRE_ID) + FORUM_PANNEAU_REDIRECT_URI (défaut : http://localhost:<port>/connexion/retour).
|
FORUM_PROPRIETAIRE_ID) + FORUM_PANNEAU_REDIRECT_URI (défaut : http://localhost:<port>/connexion/retour).
|
||||||
"""
|
"""
|
||||||
|
import threading
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
@@ -316,6 +317,16 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
def creer_serveur(forum, port=0, hote="127.0.0.1", reglages=None):
|
def creer_serveur(forum, port=0, hote="127.0.0.1", reglages=None):
|
||||||
h = type("H", (Handler,), {"app": App(forum, reglages or connexion.Reglages())})
|
h = type("H", (Handler,), {"app": App(forum, reglages or connexion.Reglages())})
|
||||||
|
# Une seule connexion SQLite partagée entre les fils : les requêtes passent une par une
|
||||||
|
# (sinon « bad parameter or other API misuse » et connexion coupée quand plusieurs arrivent ensemble).
|
||||||
|
VERROU_BASE = threading.RLock()
|
||||||
|
for nom in ("do_GET", "do_POST", "do_HEAD"):
|
||||||
|
orig = getattr(h, nom, None)
|
||||||
|
if orig is not None:
|
||||||
|
def enveloppe(self, _orig=orig):
|
||||||
|
with VERROU_BASE:
|
||||||
|
return _orig(self)
|
||||||
|
setattr(h, nom, enveloppe)
|
||||||
return ThreadingHTTPServer((hote, port), h)
|
return ThreadingHTTPServer((hote, port), h)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2049,6 +2049,16 @@ def form_supprimer(action, champ, ident, classe="suppr", resume="Supprimer", aid
|
|||||||
|
|
||||||
def creer_serveur(forum, port=0, hote="127.0.0.1", reglages=None):
|
def creer_serveur(forum, port=0, hote="127.0.0.1", reglages=None):
|
||||||
h = type("H", (Handler,), {"app": App(forum, reglages or connexion.Reglages())})
|
h = type("H", (Handler,), {"app": App(forum, reglages or connexion.Reglages())})
|
||||||
|
# Une seule connexion SQLite partagée entre les fils : les requêtes passent une par une
|
||||||
|
# (sinon « bad parameter or other API misuse » et connexion coupée quand plusieurs arrivent ensemble).
|
||||||
|
VERROU_BASE = threading.RLock()
|
||||||
|
for nom in ("do_GET", "do_POST", "do_HEAD"):
|
||||||
|
orig = getattr(h, nom, None)
|
||||||
|
if orig is not None:
|
||||||
|
def enveloppe(self, _orig=orig):
|
||||||
|
with VERROU_BASE:
|
||||||
|
return _orig(self)
|
||||||
|
setattr(h, nom, enveloppe)
|
||||||
return ThreadingHTTPServer((hote, port), h)
|
return ThreadingHTTPServer((hote, port), h)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Référencer dans un nouveau ticket
Bloquer un utilisateur