Skip to content

Commit 8947b59

Browse files
committed
fix for process.wait for long running processes
1 parent 7bd49a1 commit 8947b59

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

cloudconvert/process.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import time
34

45
from .exceptions import (
56
APIError, HTTPError, BadRequest, ConversionFailed, TemporaryUnavailable, InvalidResponse, InvalidParameterException
@@ -60,14 +61,17 @@ def delete(self):
6061

6162

6263

63-
def wait(self):
64+
def wait(self, interval = 1):
6465
"""
65-
Waits for the Process to finish (or end with an error)
66+
Waits for the Process to finish (or end with an error). Checks the conversion status every interval seconds.
67+
:param int interval: Interval in seconds
6668
:raises APIError: if the CloudConvert API returns an error
6769
"""
68-
if self['step']=='finished' or self['step'] =='error':
69-
return self
70-
return self.refresh({'wait': 'true'})
70+
while self['step']!='finished' and self['step'] !='error':
71+
self.refresh()
72+
time.sleep(interval)
73+
74+
return self
7175

7276

7377

0 commit comments

Comments
 (0)