当前位置: 首页>>代码示例>>Python>>正文


Python Timer.name方法代码示例

本文整理汇总了Python中threading.Timer.name方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.name方法的具体用法?Python Timer.name怎么用?Python Timer.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading.Timer的用法示例。


在下文中一共展示了Timer.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_prices

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def update_prices(self, app):
     price_timer = Timer(
         60.0,
         self.update_prices,
         kwargs={'app': app}
     )
     price_timer.name = 'price_timer'
     price_timer.daemon = True
     price_timer.start()
     conn = database.get_db(app)
     db = conn.cursor()
     for unit in app.config['units']:
         self.log.info('fetching price for {}'.format(unit))
         streamer_price = self.streamer.get_price(unit)
         if streamer_price is None:
             price = self.standard.get_price(unit)
             self.log.warn('price streamer offline!')
         else:
             price = streamer_price
         db.execute(
             "INSERT INTO prices (unit, price) VALUES (%s,%s)", (
                 unit,
                 price
             )
         )
         self.log.info('{} price set to {}'.format(unit, price))
     conn.commit()
     conn.close()
开发者ID:inuitwallet,项目名称:ALP-Server,代码行数:30,代码来源:price_fetcher.py

示例2: defer

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def defer(self, t, run_on_cancel, func, *args):
     event = Timer(t, self.run_action, kwargs={'func': func, 'args': args})
     event.name = '%s deferring %s' % (event.name, func.__name__)
     event.start()
     with worker_lock:
         self.events[event.ident] = Event(event, run_on_cancel)
     return event.ident
开发者ID:bobtwinkles,项目名称:cslbot,代码行数:9,代码来源:workers.py

示例3: _iter

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
    def _iter(self, con, evt, i, prev=0):

        result = self._check_iteration(evt, i)

        if not result:
            try:
                if i <= 1:
                    self.automated_run.plot_panel.counts = 1
                else:
                    self.automated_run.plot_panel.counts += 1
            except AttributeError:
                pass

            if not self._iter_hook(con, i):
                evt.set()
                return

            ot = time.time()
            p = self.period_ms * 0.001
            t = Timer(max(0, p - prev), self._iter, args=(con, evt, i + 1,
                                                          time.time() - ot))

            t.name = 'iter_{}'.format(i + 1)
            t.start()

        else:
            if result == 'cancel':
                self.canceled = True
            elif result == 'terminate':
                self.terminated = True

            #self.debug('no more iter')
            evt.set()
开发者ID:UManPychron,项目名称:pychron,代码行数:35,代码来源:data_collector.py

示例4: _dumper

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def _dumper():
     def _dump():
         task.kill()
         dump_signal(None, None)
     timer = Timer(10.0, _dump)
     timer.name = "MainThreadHearthbeatCheck"
     timer.daemon = True
     timer.start()
     GLib.idle_add(timer.cancel)
开发者ID:B-Rich,项目名称:entropy,代码行数:11,代码来源:rigo_app.py

示例5: startservice

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def startservice(self):
     # Start a thread that waits for inputs
     receiver_thread = Thread(target=self.server_loop, name='ReceiverThread')
     receiver_thread.start()
     # Start a thread with the server which will start a thread for each request
     main_thread = Thread(target=self.handle_messages, name='MainThread')
     main_thread.start()
     # Start a thread that waits for inputs
     input_thread = Thread(target=self.get_user_input_from_shell, name='InputThread')
     input_thread.start()
     # Start a thread that pings all neighbors
     ping_thread = Timer(LIVENESSTIMEOUT, self.ping_neighbor)
     ping_thread.name = 'PingThread'
     ping_thread.start()
     # Start a thread that goes through the nascentset and cleans expired ones
     nascent_thread = Timer(NASCENTTIMEOUT, self.clean_nascent)
     nascent_thread.name = 'NascentThread'
     nascent_thread.start()
     return self
开发者ID:chrisy,项目名称:concoord,代码行数:21,代码来源:node.py

示例6: take_observation

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
    def take_observation(self, observation, headers=None, **kwargs):
        camera_event = Event()

        if headers is None:
            headers = {}

        start_time = headers.get('start_time', current_time(flatten=True))

        filename = "solved.{}".format(self.file_extension)

        file_path = "{}/pocs/tests/data/{}".format(os.getenv('POCS'), filename)

        image_id = '{}_{}_{}'.format(
            self.config['name'],
            self.uid,
            start_time
        )
        self.logger.debug("image_id: {}".format(image_id))

        sequence_id = '{}_{}_{}'.format(
            self.config['name'],
            self.uid,
            observation.seq_time
        )

        # Camera metadata
        metadata = {
            'camera_name': self.name,
            'camera_uid': self.uid,
            'field_name': observation.field.field_name,
            'file_path': file_path,
            'filter': self.filter_type,
            'image_id': image_id,
            'is_primary': self.is_primary,
            'sequence_id': sequence_id,
            'start_time': start_time,
        }
        metadata.update(headers)
        exp_time = kwargs.get('exp_time', observation.exp_time.value)

        exp_time = 5
        self.logger.debug("Trimming camera simulator exposure to 5 s")

        self.take_exposure(seconds=exp_time, filename=file_path)

        # Add most recent exposure to list
        observation.exposure_list[image_id] = file_path.replace('.cr2', '.fits')

        # Process the image after a set amount of time
        wait_time = exp_time + self.readout_time
        t = Timer(wait_time, self.process_exposure, (metadata, camera_event,))
        t.name = '{}Thread'.format(self.name)
        t.start()

        return camera_event
开发者ID:panoptes,项目名称:POCS,代码行数:57,代码来源:simulator.py

示例7: startservice

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def startservice(self):
     # Start a thread that waits for inputs
     receiver_thread = Thread(target=self.server_loop, name='ReceiverThread')
     receiver_thread.start()
     # Start a thread with the server which will start a thread for each request
     main_thread = Thread(target=self.handle_messages, name='MainThread')
     main_thread.start()
     # Start a thread that waits for inputs
     #input_thread = Thread(target=self.get_user_input_from_shell, name='InputThread')
     #input_thread.start()
     # Start a thread that pings neighbors
     timer_thread = Timer(ACKTIMEOUT/5, self.periodic)
     timer_thread.name = 'PeriodicThread'
     timer_thread.start()
     return self
开发者ID:kunthar,项目名称:concoord,代码行数:17,代码来源:node.py

示例8: _add_recent_search_safe

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
    def _add_recent_search_safe(self, search):
        """
        Add text element to recent searches.
        """
        if len(search) < self.MIN_RECENT_SEARCH_KEY_LEN:
            return

        if search not in self._search_completion_model_set:
            def _prepend():
                self._search_completion_model.prepend((search,))
                self._search_completion_model_set.add(search)
            GLib.idle_add(_prepend)

        with self._search_writeback_mutex:
            if self._search_writeback_thread is None:
                task = Timer(15.0, self._store_searches_thread)
                task.name = "StoreRecentSearches"
                task.daemon = True
                self._search_writeback_thread = task
                task.start()
开发者ID:Heather,项目名称:entropy,代码行数:22,代码来源:applications.py

示例9: _iter

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
    def _iter(self, con, evt, i, prev=0):
        if not self._check_iteration(evt, i):
            if not self._iter_hook(con, i):
                evt.set()
                return

            ot = time.time()

            p = self.period_ms * 0.001
            p -= prev
            p = max(0, p)

            #self.debug('period {} {} {}'.format(p,prev, self.period_ms))
            t = Timer(p, self._iter, args=(con, evt, i + 1,
                                           time.time() - ot))

            t.name = 'iter_{}'.format(i + 1)
            t.start()

        else:
            #self.debug('no more iter')
            evt.set()
开发者ID:jirhiker,项目名称:pychron,代码行数:24,代码来源:data_collector.py

示例10: paint

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def paint(self, canvas):
     g15theme.G15Page.paint(self, canvas)
     wait = self._frame_wait
     size = self._screen.driver.get_size()
         
     if self._playing != None:
         
         # Process may have been killed
         if not self._playing._playing():
             self._stop()
         
         dir = sorted(os.listdir(self._playing.temp_dir), reverse=True)
         if len(dir) > 1:
             dir = dir[1:]
             file = os.path.join(self._playing.temp_dir, dir[0])
             self._surface = g15cairo.load_surface_from_file(file)
             for path in dir:
                 file = os.path.join(self._playing.temp_dir, path)
                 os.remove(file)
         else:
             wait = 0.1
         
         if self._surface != None:
             target_size = ( float(size[0]), float(size[0]) * (float(self._aspect[1]) ) / float(self._aspect[0]) )
             sx = float(target_size[0]) / float(self._surface.get_width())
             sy = float(target_size[1]) / float(self._surface.get_height())
             canvas.save()
             canvas.translate((size[0] - target_size[0]) / 2.0,(size[1] - target_size[1]) / 2.0)
             canvas.scale(sx, sy)
             canvas.set_source_surface(self._surface)
             canvas.paint()
             canvas.restore()   
     
     if self._playing != None:
         timer = Timer(wait, self.redraw)
         timer.name = "VideoRedrawTimer"
         timer.setDaemon(True)
         timer.start()
开发者ID:FPar,项目名称:gnome15,代码行数:40,代码来源:oldvideoplayer.py

示例11: take_observation

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
    def take_observation(self, observation, headers=None, filename=None, **kwargs):
        """Take an observation

        Gathers various header information, sets the file path, and calls `take_exposure`. Also creates a
        `threading.Event` object and a `threading.Timer` object. The timer calls `process_exposure` after the
        set amount of time is expired (`observation.exp_time + self.readout_time`).

        Note:
            If a `filename` is passed in it can either be a full path that includes the extension,
            or the basename of the file, in which case the directory path and extension will be added
            to the `filename` for output

        Args:
            observation (~pocs.scheduler.observation.Observation): Object describing the observation
            headers (dict): Header data to be saved along with the file
            filename (str, optional): Filename for saving, defaults to ISOT time stamp
            **kwargs (dict): Optional keyword arguments (`exp_time`)

        Returns:
            threading.Event: An event to be set when the image is done processing
        """
        # To be used for marking when exposure is complete (see `process_exposure`)
        camera_event = Event()

        if headers is None:
            headers = {}

        start_time = headers.get('start_time', current_time(flatten=True))

        # Get the filename
        image_dir = "{}/fields/{}/{}/{}/".format(
            self.config['directories']['images'],
            observation.field.field_name,
            self.uid,
            observation.seq_time,
        )

        # Get full file path
        if filename is None:
            file_path = "{}/{}.{}".format(image_dir, start_time, self.file_extension)
        else:
            # Add extension
            if '.' not in filename:
                filename = '{}.{}'.format(filename, self.file_extension)

            # Add directory
            if '/' not in filename:
                filename = '{}/{}'.format(image_dir, filename)

            file_path = filename

        image_id = '{}_{}_{}'.format(
            self.config['name'],
            self.uid,
            start_time
        )
        self.logger.debug("image_id: {}".format(image_id))

        sequence_id = '{}_{}_{}'.format(
            self.config['name'],
            self.uid,
            observation.seq_time
        )

        # Camera metadata
        metadata = {
            'camera_name': self.name,
            'camera_uid': self.uid,
            'field_name': observation.field.field_name,
            'file_path': file_path,
            'filter': self.filter_type,
            'image_id': image_id,
            'is_primary': self.is_primary,
            'sequence_id': sequence_id,
            'start_time': start_time,
        }
        metadata.update(headers)
        exp_time = kwargs.get('exp_time', observation.exp_time.value)
        proc = self.take_exposure(seconds=exp_time, filename=file_path)

        # Add most recent exposure to list
        observation.exposure_list[image_id] = file_path.replace('.cr2', '.fits')

        # Process the image after a set amount of time
        wait_time = exp_time + self.readout_time
        t = Timer(wait_time, self.process_exposure, (metadata, camera_event, proc))
        t.name = '{}Thread'.format(self.name)
        t.start()

        return camera_event
开发者ID:panoptes,项目名称:POCS,代码行数:92,代码来源:canon_gphoto2.py

示例12: set_timer

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
 def set_timer():
     t = Timer(1.0, unset)
     t.name = "UnsetScrollingTimer"
     t.daemon = True
     return t
开发者ID:Sabayon,项目名称:entropy,代码行数:7,代码来源:apptreeview.py

示例13: PriceFetcher

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
if 'poloniex' in app.config['exchanges']:
    wrappers['poloniex'] = src.exchanges.Poloniex()
if 'test_exchange' in app.config['exchanges']:
    wrappers['test_exchange'] = src.exchanges.TestExchange()

# save the start time of the server for reporting up-time
app.config['start_time'] = time.time()

# set up a price fetcher object
pf = PriceFetcher(app, log)

# Set the timer for credits
log.info('running credit timer')
credit_timer = Timer(60.0, credit.credit,
                     kwargs={'app': app, 'log': log})
credit_timer.name = 'credit_timer'
credit_timer.daemon = True
credit_timer.start()

# Set the timer for payouts
log.info('running payout timer')
conn = database.get_db(app)
db = conn.cursor()
db.execute("SELECT value FROM info WHERE key = %s", ('next_payout_time',))
next_payout_time = int(db.fetchone()[0])
if next_payout_time == 0:
    payout_time = 86400
    db.execute('UPDATE info SET value=%s WHERE key=%s', (int(time.time() + payout_time),
                                                         'next_payout_time'))
else:
    payout_time = int(next_payout_time - int(time.time()))
开发者ID:inuitwallet,项目名称:ALP-Server,代码行数:33,代码来源:pool_server.py

示例14: pay

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
def pay(app, log):
    """
    Pay all users who have a balance greater than the minimum payout
    :param log:
    :param rpc:
    :param app:
    :return:
    """
    log.info('payout started')
    # get the credit details from the database
    conn = database.get_db(app)
    db = conn.cursor()
    db.execute("SELECT c.id,c.key,c.reward,u.address FROM credits AS c INNER JOIN "
               "users AS u on u.key=c.key WHERE c.paid=0")
    rewards = db.fetchall()
    # Calculate the total credit for each unique address
    user_rewards = {}
    for reward in rewards:
        if reward[3] not in user_rewards:
            user_rewards[reward[3]] = 0.00
        user_rewards[reward[3]] += float(reward[2])
    # remove those which don't meet the minimum payout threshold
    # and round to 6dp
    user_payouts = user_rewards.copy()
    for address in user_rewards:
        if user_rewards[address] < float(app.config['pool.minimum_payout']):
            del(user_payouts[address])
            continue
        user_payouts[address] = round(float(user_payouts[address]), 6)
    if not user_payouts:
        log.info('no-one to payout to: %s', user_rewards)
        timer_time = 86400.0
    else:
        # SendMany from nud. Report any error to log output
        try:
            # get an rpc connection
            rpc = get_rpc(app, log)
            rpc.sendmany("", user_payouts)
            log.info('payout successful: \'%s\'', json.dumps(user_payouts))
            # mark credits to paid addresses as paid
            for reward in rewards:
                if reward[3] in user_payouts:
                    db.execute('UPDATE credits SET paid=1 WHERE id=%s', (reward[0],))
            # set the timer for the next payout
            timer_time = 86400.0
        except JSONRPCException as e:
            log.error('Payout failed - %s: \'%s\'', e.message, json.dumps(user_payouts))
            timer_time = 120.0
        except (socket.error, CannotSendRequest, ValueError):
            log.error('Payout failed - no connection with nud: \'%s\'', json.dumps(
                    user_payouts))
            timer_time = 120.0
    # reset timer
    payout_timer = Timer(timer_time, pay,
                         kwargs={'app': app, 'log': log})
    payout_timer.name = 'payout_timer'
    payout_timer.daemon = True
    payout_timer.start()
    # update the next payout time
    db.execute('UPDATE info SET value=%s WHERE key=%s', (int(time.time() + timer_time),
                                                         'next_payout_time'))
    conn.commit()
    conn.close()
开发者ID:inuitwallet,项目名称:ALP-Server,代码行数:65,代码来源:payout.py

示例15: _setup_timer

# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import name [as 别名]
def _setup_timer():
    timer = Timer(3600, _gc_collect)
    timer.name = "HourlyGarbageCollector"
    timer.daemon = True
    timer.start()
开发者ID:pombredanne,项目名称:packages-website,代码行数:7,代码来源:__init__.py


注:本文中的threading.Timer.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。