trains/task.py
def _at_exit(self):
        """
        Will happen automatically once we exit code, i.e. atexit
        :return:
        """
        if self._at_exit_called:
            return

        # noinspection PyBroadException
        try:
            # from here do not get into watch dog
            self._at_exit_called = True
            self._dev_stop_signal = None
            self._dev_mode_periodic_flag = True
            wait_for_uploads = True
            # first thing mark task as stopped, so we will not end up with "running" on lost tasks
            # if we are running remotely, the daemon will take care of it
            if not running_remotely() and self.is_main_task():
                # from here, do not check worker status
                if self._dev_worker:
                    self._dev_worker.unregister()
                # check if we crashed, ot the signal is not interrupt (manual break)
                if self.__exit_hook:
                    if self.__exit_hook.exception is not None or \
                            (not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal not in (None, 2)):
                        self.mark_failed(status_reason='Exception')
                        wait_for_uploads = False
                    else:
                        self.stopped()
                        wait_for_uploads = (self.__exit_hook.remote_user_aborted or self.__exit_hook.signal is None)
                else:
                    self.stopped()

            # wait for uploads
            print_done_waiting = False
            if wait_for_uploads and (BackendModel.get_num_results() > 0 or self.reporter.get_num_results() > 0):
                self.log.info('Waiting to finish uploads')
                print_done_waiting = True
            # from here, do not send log in background thread
            if wait_for_uploads:
                self.flush(wait_for_uploads=True)
                if print_done_waiting:
                    self.log.info('Finished uploading')
            else:
                self._logger._flush_stdout_handler()
            self._logger.set_flush_period(None)
            # this is so in theory we can close a main task and start a new one
            Task.__main_task = None
        except Exception:
            # make sure we do not interrupt the exit process
            pass

        Will happen automatically once we exit code, i.e. atexit
        :return:
        
Will happen automatically once we exit code, i.e. atexit
Will happen automatically once we exit code i . e . atexit
def _at_exit(self):
        if self._at_exit_called:
            return
        try:
            self._at_exit_called = True
            self._dev_stop_signal = None
            self._dev_mode_periodic_flag = True
            wait_for_uploads = True
            if not running_remotely() and self.is_main_task():
                if self._dev_worker:
                    self._dev_worker.unregister()
                if self.__exit_hook:
                    if self.__exit_hook.exception is not None or \
                            (not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal not in (None, 2)):
                        self.mark_failed(status_reason='Exception')
                        wait_for_uploads = False
                    else:
                        self.stopped()
                        wait_for_uploads = (self.__exit_hook.remote_user_aborted or self.__exit_hook.signal is None)
                else:
                    self.stopped()
            print_done_waiting = False
            if wait_for_uploads and (BackendModel.get_num_results() > 0 or self.reporter.get_num_results() > 0):
                self.log.info('Waiting to finish uploads')
                print_done_waiting = True
            if wait_for_uploads:
                self.flush(wait_for_uploads=True)
                if print_done_waiting:
                    self.log.info('Finished uploading')
            else:
                self._logger._flush_stdout_handler()
            self._logger.set_flush_period(None)
            Task.__main_task = None
        except Exception:
            pass
def _at_exit ( self ) : if self . _at_exit_called : return try : self . _at_exit_called = True self . _dev_stop_signal = None self . _dev_mode_periodic_flag = True wait_for_uploads = True if not running_remotely ( ) and self . is_main_task ( ) : if self . _dev_worker : self . _dev_worker . unregister ( ) if self . __exit_hook : if self . __exit_hook . exception is not None or ( not self . __exit_hook . remote_user_aborted and self . __exit_hook . signal not in ( None , 2 ) ) : self . mark_failed ( status_reason = 'Exception' ) wait_for_uploads = False else : self . stopped ( ) wait_for_uploads = ( self . __exit_hook . remote_user_aborted or self . __exit_hook . signal is None ) else : self . stopped ( ) print_done_waiting = False if wait_for_uploads and ( BackendModel . get_num_results ( ) > 0 or self . reporter . get_num_results ( ) > 0 ) : self . log . info ( 'Waiting to finish uploads' ) print_done_waiting = True if wait_for_uploads : self . flush ( wait_for_uploads = True ) if print_done_waiting : self . log . info ( 'Finished uploading' ) else : self . _logger . _flush_stdout_handler ( ) self . _logger . set_flush_period ( None ) Task . __main_task = None except Exception : pass
Will happen automatically once we exit code, i.e.
Will happen automatically once we exit code i . e .
"""
        Will happen automatically once we exit code, i.e. atexit
        :return:
        """ # noinspection PyBroadException # from here do not get into watch dog # first thing mark task as stopped, so we will not end up with "running" on lost tasks # if we are running remotely, the daemon will take care of it # from here, do not check worker status # check if we crashed, ot the signal is not interrupt (manual break) # wait for uploads # from here, do not send log in background thread # this is so in theory we can close a main task and start a new one # make sure we do not interrupt the exit process
None
self