示例#1
0
    def wait(self,
             jobname,
             poll_interval=2,
             timeout=None,
             clean=False,
             show=None):
        """
        Block until the job has finished.
        Returns a list of the result urls.

        :type  poll_interval: int
        :param poll_interval: the number of seconds between job status requests.

        :type  timeout: int or None
        :param timeout: if specified, the number of seconds before returning or
                        raising a :class:`disco.JobError`.

        :type  clean: bool
        :param clean: if `True`,
                      call :meth:`Disco.clean` when the job has finished.

                      .. deprecated:: 0.4

        :type  show: bool or string
        :param show: enables console output of job events.
                     The default is provided by :envvar:`DISCO_EVENTS`.

                     .. versionadded:: 0.2.3
        """
        if show is None:
            show = self.settings['DISCO_EVENTS']
        event_monitor = EventMonitor(Job(name=jobname, master=self.master),
                                     format=show,
                                     poll_interval=poll_interval)
        start_time = time.time()
        try:
            while True:
                event_monitor.refresh()
                try:
                    return self.check_results(jobname, start_time, timeout,
                                              poll_interval * 1000)
                except Continue:
                    continue
                finally:
                    if clean:
                        self.clean(jobname)
                    event_monitor.refresh()
        finally:
            event_monitor.cleanup()
示例#2
0
文件: core.py 项目: hmas/disco
    def wait(self, jobname, poll_interval=20, timeout=None, clean=False, show=None):
        """
        Block until the job has finished.
        Returns a list of the result urls.

        :type  poll_interval: int
        :param poll_interval: the number of seconds between job status requests.

        :type  timeout: int or None
        :param timeout: if specified, the number of seconds before returning or
                        raising a :class:`disco.JobError`.

        :type  clean: bool
        :param clean: if `True`,
                      call :meth:`Disco.clean` when the job has finished.

                      .. deprecated:: 0.4

        :type  show: bool or string
        :param show: enables console output of job events.
                     The default is provided by :envvar:`DISCO_EVENTS`.

                     .. versionadded:: 0.2.3
        """
        if show is None:
            show = self.settings['DISCO_EVENTS']
        event_monitor = EventMonitor(Job(name=jobname, master=self.master),
                                     format=show,
                                     poll_interval=poll_interval)
        start_time    = time.time()
        try:
            while True:
                event_monitor.refresh()
                try:
                    return self.check_results(jobname, start_time,
                                              timeout, poll_interval * 1000)
                except Continue:
                    continue
                finally:
                    if clean:
                        self.clean(jobname)
                    event_monitor.refresh()
        finally:
            event_monitor.cleanup()