Calling subprocess on Invoice post button

Hello, I’ve a weird situation and I wondering is someone has the time to point me in the right direction:

  1. Before posting and invoice I’m calling a script with subprocess
  2. All good, but checking the logs seems that gets called twice, always twice.
  3. I tried calling the script from python3 interpreter >>> but here the script runs only one time.

Question is:
¿I’m using uswgi, maybe is related to threads, workers or something like that? Using trytond I can see only one call to .post[invoice_id] but my script gets called twice, one time and then 5 seconds after the script completes…second time. Sorry if this is not directly related to tryton it self, maybe an internal timeout to retry exists?

    def post(cls, invoices):
        for invoice in invoices:
                rs = subprocess.check_output(["python3.7", "",str(,str(invoice.type)])
            except Exception as e:
                raise UserError('Error al llamar el subproceso : {}'.format(e))

Yes post may be called multiple times by the process method. The workflow transition method must always be designed as being kinda idempotent.
Also trytond is a transactional system which means that a state change are recorded only if the full transaction is succeeding otherwise it is rollbacked and it may be retried later.

By the way I do not see the point to call a python script with a sub-process, you could run the main method directly.

Thank you, that was scratching my mind. I will try to remove that subprocess call for sure.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.