コード例 #1
0
ファイル: data_collector.py プロジェクト: UManPychron/pychron
    def _measure(self, evt):
        self.debug('starting measurment')
        with consumable(func=self._iter_step) as con:
            self._iter(con, evt, 1)
            while not evt.is_set():
                time.sleep(0.05)

        self.debug('measurement finished')
コード例 #2
0
ファイル: data_collector.py プロジェクト: sgallet/pychron
    def _measure(self, evt):
        self.debug('starting measurment')
        with consumable(func=self._iter_step) as con:
            self._iter(con, evt, 1)
            while not evt.is_set():
                time.sleep(0.25)

        self.debug('measurement finished')
コード例 #3
0
ファイル: looper.py プロジェクト: waffle-iron/pychron
def loop():
    i = 0
    n = 100

    print '{} '.format(get_mem())
    with consumable():
        print '{} '.format(get_mem())
        while 1:
            if i > n:
                break
            time.sleep(0.05)
            i += 1
            if not i % 10:
                print i

    print '{} '.format(get_mem())
コード例 #4
0
ファイル: looper.py プロジェクト: NMGRL/pychron
def loop():
    i = 0
    n = 100


    print '{} '.format(get_mem())
    with consumable():
        print '{} '.format(get_mem())
        while 1:
            if i > n:
                break
            time.sleep(0.05)
            i += 1
            if not i % 10:
                print i

    print '{} '.format(get_mem())
コード例 #5
0
    def _execute_queue(self, i, exp):
        self.experiment_queue = exp
        self.info('Starting automated runs set={:02n} {}'.format(i, exp.name))

        # save experiment to database
        self.info('saving experiment "{}" to database'.format(exp.name))

        with self.db.session_ctx():
            dbexp = self.db.add_experiment(exp.path)
            exp.database_identifier = int(dbexp.id)

        exp.executed = True
        # scroll to the first run
        exp.automated_runs_scroll_to_row = 0

        delay = exp.delay_between_analyses
        force_delay = False
        last_runid = None

        rgen, nruns = exp.new_runs_generator()

        cnt = 0
        total_cnt = 0
        with consumable(func=self._overlapped_run) as con:
            while 1:
            #                 before = measure_type()
                if not self.isAlive():
                    break

                if self._pre_run_check():
                    self.debug('pre run check failed')
                    break

                if self.queue_modified:
                    self.debug('Queue modified. making new run generator')
                    rgen, nruns = exp.new_runs_generator()
                    cnt = 0
                    self.queue_modified = False
                    #                    force_delay = True

                overlapping = self.current_run and self.current_run.isAlive()
                if not overlapping:
                    if force_delay or \
                            (self.isAlive() and cnt < nruns and not cnt == 0):
                        # delay between runs
                        self._delay(delay)
                        force_delay = False

                try:
                    spec = rgen.next()

                except StopIteration:
                    self.debug('stop iteration')
                    break

                self._check_run_aliquot(spec)

                run = self._make_run(spec)
                self.wait_group.active_control.page_name = run.runid

                if spec.analysis_type == 'unknown' and spec.overlap:
                    self.info('overlaping')
                    t = Thread(target=self._do_run, args=(run,))
                    t.start()
                    run.wait_for_overlap()

                    self.debug('overlap finished. starting next run')

                    con.add_consumable((t, run))
                else:
                    last_runid = run.runid
                    self._join_run(spec, run)

                cnt += 1
                total_cnt += 1
                if self.end_at_run_completion:
                    break

        if self._err_message:
            self.warning('automated runs did not complete successfully')
            self.warning('error: {}'.format(self._err_message))

        self._end_runs()
        if last_runid:
            self.info('Automated runs ended at {}, runs executed={}'.format(last_runid, total_cnt))

        self.info_heading('experiment queue {} finished'.format(exp.name))
コード例 #6
0
    def _execute_queue(self, i, exp):
        self.experiment_queue = exp
        self.info('Starting automated runs set={:02n} {}'.format(i, exp.name))

        # save experiment to database
        self.info('saving experiment "{}" to database'.format(exp.name))

        with self.db.session_ctx():
            dbexp = self.db.add_experiment(exp.path)
            exp.database_identifier = int(dbexp.id)

        exp.executed = True
        # scroll to the first run
        exp.automated_runs_scroll_to_row = 0

        delay = exp.delay_between_analyses
        force_delay = False
        last_runid = None

        rgen, nruns = exp.new_runs_generator()

        cnt = 0
        total_cnt = 0
        with consumable(func=self._overlapped_run) as con:
            while 1:
                #                 before = measure_type()
                if not self.isAlive():
                    break

                if self._pre_run_check():
                    self.debug('pre run check failed')
                    break

                if self.queue_modified:
                    self.debug('Queue modified. making new run generator')
                    rgen, nruns = exp.new_runs_generator()
                    cnt = 0
                    self.queue_modified = False
                    #                    force_delay = True

                overlapping = self.current_run and self.current_run.isAlive()
                if not overlapping:
                    if force_delay or \
                            (self.isAlive() and cnt < nruns and not cnt == 0):
                        # delay between runs
                        self._delay(delay)
                        force_delay = False

                try:
                    spec = rgen.next()

                except StopIteration:
                    self.debug('stop iteration')
                    break

                self._check_run_aliquot(spec)

                run = self._make_run(spec)
                self.wait_group.active_control.page_name = run.runid

                if spec.analysis_type == 'unknown' and spec.overlap:
                    self.info('overlaping')
                    t = Thread(target=self._do_run, args=(run, ))
                    t.start()
                    run.wait_for_overlap()

                    self.debug('overlap finished. starting next run')

                    con.add_consumable((t, run))
                else:
                    last_runid = run.runid
                    self._join_run(spec, run)

                cnt += 1
                total_cnt += 1
                if self.end_at_run_completion:
                    break

        if self._err_message:
            self.warning('automated runs did not complete successfully')
            self.warning('error: {}'.format(self._err_message))

        self._end_runs()
        if last_runid:
            self.info('Automated runs ended at {}, runs executed={}'.format(
                last_runid, total_cnt))

        self.info_heading('experiment queue {} finished'.format(exp.name))