0

I have a certain job in python called "exportjob" (this job basically execute a procedure in external application). I need that python wait the execution of the code until a variable assume a specific value. More precisely: a) the command for exportjob is:

exportJob = client.service.SubmitExportJob(USER, CLIENTID, PW, "MB_ExportSet_Portfolio", dt.date(2020, 4, 16), "Exporting Job", True)

b) then i get the status of this exportjob by using this command (simply passing him the exportjob variable in the command)

status = client.service.GetExportJobStatus(USER, CLIENTID, PW, exportJob)

c) the status variable return immediately only one of these values: status= 0 'Export completed succesfully', status<0 'Export failed', status>0 'Export is pending'

I want to tell python (if status>0) TO WAIT UNTIL status=0 (or stopping procedure if status<0) Someone can help me?

Ig_Ferr
  • 61
  • 1
  • 7

1 Answers1

0

You can do this with a simple while loop

status = client.service.GetExportJobStatus(USER, CLIENTID, PW, exportJob)
while status > 0:
    status = client.service.GetExportJobStatus(USER, CLIENTID, PW, exportJob)
    sleep(0.1) #not needed but could be used to decrease number of iterations (pauses program for 0.1 seconds)
#new status is either =0 or <0 so you can execute the rest of your program
  • Thank you very much, now it work properly. Can i ask you another question if possible? Soon after submitting the job and successfully exported status, i get the file with another job like this: dataWrk = client.service.GetExportJob(USER, CLIENTID, PW, exportJob). I need to link the dataWrk to a zip object file and then extract it. I'm working under soap SUDS JURKO – Ig_Ferr Apr 22 '20 at 12:03
  • No problem. But since I have never worked with SOAP in python I'm afraid I can't be of any help. If you are asking about sending a zip object you could check out [How to send a file through Soap in python?](https://stackoverflow.com/questions/6601107/how-to-send-a-file-through-soap-in-python). – Willem Govaerts Apr 22 '20 at 18:23