def wait_for_request(pbclient, request_id,<EOL>timeout=<NUM_LIT:0>, initial_wait=<NUM_LIT:5>, scaleup=<NUM_LIT:10>):
total_wait = <NUM_LIT:0><EOL>wait_period = initial_wait<EOL>next_scaleup = scaleup * wait_period<EOL>wait = True<EOL>while wait:<EOL><INDENT>request_status = pbclient.get_request(request_id, status=True)<EOL>state = request_status['<STR_LIT>']['<STR_LIT:status>']<EOL>if state == "<STR_LIT>":<EOL><INDENT>return(<NUM_LIT:0>, state, request_status['<STR_LIT>']['<STR_LIT:message>'])<EOL><DEDENT>if state == '<STR_LIT>':<EOL><INDENT>return(<NUM_LIT:1>, state, request_status['<STR_LIT>']['<STR_LIT:message>'])<EOL><DEDENT>print("<STR_LIT>"<EOL>.format(request_id, state, wait_period))<EOL>sleep(wait_period)<EOL>total_wait += wait_period<EOL>if timeout != <NUM_LIT:0> and total_wait > timeout:<EOL><INDENT>wait = False<EOL><DEDENT>next_scaleup -= wait_period<EOL>if next_scaleup == <NUM_LIT:0>:<EOL><INDENT>wait_period += initial_wait<EOL>next_scaleup = scaleup * wait_period<EOL>print("<STR_LIT>"<EOL>.format(wait_period, next_scaleup))<EOL><DEDENT><DEDENT>return(-<NUM_LIT:1>, state, "<STR_LIT>")<EOL>
Waits for a request to finish until timeout.
timeout==0 is interpreted as infinite wait time.
Returns a tuple (return code, request status, message) where return code
0  : request successful
1  : request failed
-1 : timeout exceeded
The wait_period is increased every scaleup steps to adjust for long
running requests.