wait_for(self, pids=[], status_list=process_result_statuses)

        Waits for a process to finish

        :Parameters:
        * *pids* (`list`) -- list of processes waiting to be finished
        * *status_list* (`list`) -- optional - List of statuses to wait for processes to finish with

        :Example:
        .. code-block:: python

           pid = opereto_client.create_process(service='simple_shell_command', title='Test simple shell command service')
           opereto_client.wait_for([pid], ['failure', 'error'])
           opereto_client.rerun_process(pid)

def wait_for(self, pids=[], status_list=process_result_statuses):
        '''
        wait_for(self, pids=[], status_list=process_result_statuses)

        Waits for a process to finish

        :Parameters:
        * *pids* (`list`) -- list of processes waiting to be finished
        * *status_list* (`list`) -- optional - List of statuses to wait for processes to finish with

        :Example:
        .. code-block:: python

           pid = opereto_client.create_process(service='simple_shell_command', title='Test simple shell command service')
           opereto_client.wait_for([pid], ['failure', 'error'])
           opereto_client.rerun_process(pid)

        '''
        results={}
        pids = self._get_pids(pids)
        for pid in pids:
            while(True):
                try:
                    stat = self._call_rest_api('get', '/processes/'+pid+'/status', error='Failed to fetch process [%s] status'%pid)
                    if stat in status_list:
                        results[pid]=stat
                        break
                    time.sleep(5)
                except requests.exceptions.RequestException as e:
                    # reinitialize session using api call decorator
                    self.session=None
                    raise e
        return results