Project

General

Profile

Development #55571

Provisionning HTTP : utiliser le spooler uwsgi

Added by Emmanuel Cazenave 18 days ago. Updated 16 days ago.

Status:
Solution proposée
Priority:
Normal
Target version:
-
Start date:
13 Jul 2021
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:
No

Description

Comme dans #55092.


Files


Related issues

Related to Hobo - Development #55092: Provisionning des roles de des utilisateurs : utiliser les spooler uwsgiSolution proposée22 Jun 2021

Actions

History

#1

Updated by Emmanuel Cazenave 18 days ago

  • Related to Development #55092: Provisionning des roles de des utilisateurs : utiliser les spooler uwsgi added
#2

Updated by Emmanuel Cazenave 18 days ago

C'est un peu galère, provision_role et provision_user ont besoin d'un objet publisher, que pickle refuse de sérialiser :

TypeError: cannot serialize '_io.TextIOWrapper' object
#3

Updated by Frédéric Péters 18 days ago

Je ne sais pas de quel code tu parles.

L'exécution asynchrone dans w.c.s. passe par l'ajout de (after)jobs; si tu utilises ça, tu n'auras pas de problèmes.

#4

Updated by Emmanuel Cazenave 16 days ago

+++ b/wcs/ctl/hobo_notify.py
@@ -24,10 +24,27 @@ from wcs.admin.settings import UserFieldsFormDef
 from wcs.qommon import force_str
 from wcs.qommon.misc import json_encode_helper

+from ..qommon.afterjobs import AfterJob
 from ..qommon.ctl import Command
 from ..qommon.publisher import get_cfg

+class ProvisionAfterJob(AfterJob):
+    def __init__(self, object_type, publisher, issuer, action, data, full, **kwargs):
+        super().__init__(**kwargs)
+        self.object_type = object_type
+        self.publisher = publisher
+        self.issuer = issuer
+        self.action = action
+        self.data = data
+        self.full = full
+
+    def execute(self):
+        getattr(CmdHoboNotify, 'provision_' + self.object_type)(
+            self.publisher, self.issuer, self.action, self.data, full=self.full
+        )
+
+
 class CmdHoboNotify(Command):
     name = 'hobo_notify'

@@ -90,7 +107,15 @@ class CmdHoboNotify(Command):

         t = notification['objects']['@type']
         # Now provision/deprovision
-        getattr(cls, 'provision_' + t)(publisher, issuer, action, notification['objects']['data'], full=full)
+        job = ProvisionAfterJob(
+            object_type=t,
+            publisher=publisher,
+            issuer=issuer,
+            action=action,
+            data=notification['objects']['data'],
+            full=full,
+        )
+        job.run(spool=True)

Avec job.run qui fait un self.store() qui appelle pickle qui plante.

#5

Updated by Frédéric Péters 16 days ago

Tu n'as pas à stocker le publisher, tu l'obtiens via get_publisher.

#6

Updated by Emmanuel Cazenave 16 days ago

Merci.

Encore plus simple que mon patch initial en fait.

Also available in: Atom PDF