當前位置: 首頁>>代碼示例>>Python>>正文


Python gevent.GreenletExit方法代碼示例

本文整理匯總了Python中gevent.GreenletExit方法的典型用法代碼示例。如果您正苦於以下問題:Python gevent.GreenletExit方法的具體用法?Python gevent.GreenletExit怎麽用?Python gevent.GreenletExit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gevent的用法示例。


在下文中一共展示了gevent.GreenletExit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _age_out_loop

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _age_out_loop(self, fieldidx):
        interval = self.fields[fieldidx].get('age_out', '30d')
        interval = _age_out_in_usecs(interval)
        t = self.tables[fieldidx]

        while True:
            try:
                now = utc_millisec()
                for i, v in t.query(index='last_seen', to_key=now-interval,
                                    include_value=True):
                    LOG.debug('%s - %s %s aged out', self.name, i, v)
                    self.emit_withdraw(indicator=i)
                    t.delete(i)

            except gevent.GreenletExit:
                break

            except:
                LOG.exception('Exception in _age_out_loop')

            gevent.sleep(self.age_out_interval) 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:23,代碼來源:panos.py

示例2: _user_id

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _user_id(self, cmd=None):
        try:
            self.xapi.user_id(cmd=cmd,
                              vsys=self.device.get('vsys', None))

        except gevent.GreenletExit:
            raise

        except pan.xapi.PanXapiError as e:
            LOG.debug('%s', e)
            if 'already exists, ignore' in str(e):
                pass
            elif 'does not exist, ignore unreg' in str(e):
                pass
            elif 'Failed to register' in str(e):
                pass
            else:
                LOG.exception('XAPI exception in pusher for device %s: %s',
                              self.device.get('hostname', None), str(e))
                raise 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:22,代碼來源:dag_ng.py

示例3: _run

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _run(self):
        self._init_resync()

        while True:
            try:
                op, address, value = self.q.peek()
                self._push(op, address, value)
                self.q.get()  # discard processed message

            except gevent.GreenletExit:
                break

            except pan.xapi.PanXapiError as e:
                LOG.exception('XAPI exception in pusher for device %s: %s',
                              self.device.get('hostname', None), str(e))
                raise 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:18,代碼來源:dag.py

示例4: _device_pusher_died

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _device_pusher_died(self, g):
        try:
            g.get()

        except gevent.GreenletExit:
            pass

        except Exception:
            LOG.exception('%s - exception in greenlet for %s, '
                          'respawning in 60 seconds',
                          self.name, g.device['hostname'])

            for idx in range(len(self.device_pushers)):
                if self.device_pushers[idx].device == g.device:
                    break
            else:
                LOG.info('%s - device pusher for %s removed,' +
                         ' respawning aborted',
                         self.name, g.device['hostname'])
                g = None
                return

            dp = self._spawn_device_pusher(g.device)
            self.device_pushers[idx] = dp
            dp.start_later(60) 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:27,代碼來源:dag.py

示例5: _publisher

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _publisher(self):
        while True:
            self._xmpp_client_ready.wait()

            try:
                while True:
                    cmd, indicator, value = self.q.peek()
                    if value is None:
                        value = {}
                    value['origins'] = [self.jid]
                    self._xmpp_publish(cmd, {
                        'indicator': indicator,
                        'value': value
                    })
                    _ = self.q.get()

            except gevent.GreenletExit:
                break

            except Exception as e:
                LOG.exception('%s - Exception in publishing message', self.name)
                gevent.sleep(30)
                self.statistics['xmpp.publish_error'] += 1 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:25,代碼來源:xmpp.py

示例6: _command_age_out

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _command_age_out(self):
        with self.state_lock:
            if self.state != ft_states.STARTED:
                return

            try:
                now = utc_millisec()

                for i, v in self.table.query(index='_age_out',
                                             to_key=now-1,
                                             include_value=True):
                    indicator, _ = i.split('\0', 1)

                    self.emit_withdraw(indicator=indicator, value=v)
                    self.table.delete(i)

                    self.statistics['aged_out'] += 1

                self.last_ageout_run = now

            except gevent.GreenletExit:
                raise

            except:
                LOG.exception('Exception in _age_out_loop') 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:27,代碼來源:syslog.py

示例7: _age_out_loop

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _age_out_loop(self):
        while True:
            with self.state_lock:
                if self.state != ft_states.STARTED:
                    break

            self._actor_queue.put(
                (utc_millisec(), 'age_out')
            )

            if self.age_out['interval'] is None:
                break

            try:
                gevent.sleep(self.age_out['interval'])
            except gevent.GreenletExit:
                break 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:19,代碼來源:basepoller.py

示例8: _actor_loop

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _actor_loop(self):
        while True:
            acommand = self._actor_queue.get()

            if acommand.command == 'checkpoint':
                method = super(ActorBaseFT, self).checkpoint
            elif acommand.command == 'update':
                method = super(ActorBaseFT, self).update
            elif acommand.command == 'withdraw':
                method = super(ActorBaseFT, self).withdraw
            elif acommand.command == 'rebuild':
                method = self._rebuild
            else:
                LOG.error('{} - unknown command {}'.format(self.name, acommand.command))

            try:
                method(**acommand.kwargs_)
            except gevent.GreenletExit:
                break
            except:
                LOG.exception('{} - error executing {!r}'.format(self.name, acommand)) 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:23,代碼來源:actorbase.py

示例9: _OpenImpl

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _OpenImpl(self):
    while self._state != ChannelState.Closed:
      try:
        self._server_set_provider.Initialize(
            self.__OnServerSetJoin,
            self.__OnServerSetLeave)
        server_set = self._server_set_provider.GetServers()
      except gevent.GreenletExit:
        return
      except:
        self._log.exception("Unable to initialize serverset, retrying in 5 seconds.")
        gevent.sleep(5)
        continue

      random.shuffle(server_set)
      self._servers = {}
      [self.__AddServer(m) for m in server_set]
      self.__init_done.set()
      self._OpenInitialChannels()
      self._open_greenlet = None
      self._state = ChannelState.Open
      return True 
開發者ID:steveniemitz,項目名稱:scales,代碼行數:24,代碼來源:base.py

示例10: _process_minute_slices

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _process_minute_slices(self, flush=False):
        """ Goes through our internal aggregated share data structures and
        reports them to our external storage. If asked to flush it will report
        all one minute shares, otherwise it will only report minutes that have
        passed. """
        self.logger.info("Reporting one minute shares for address/workers")
        t = time.time()
        if not flush:
            upper = (int(t) // 60) * 60
        for stamp, data in self._minute_slices.items():
            if flush or stamp < upper:
                for (address, worker, algo, typ), amount in data.iteritems():
                    self.log_one_minute(address, worker, algo, stamp, typ, amount)
                    # XXX: GreenletExit getting raised here might cause some
                    # double reporting!
                del self._minute_slices[stamp]

        self.logger.info("One minute shares reported in {}"
                         .format(time_format(time.time() - t)))

        # Clean up old per address slices as well
        ten_ago = ((time.time() // 60) * 60) - 600
        for stamp in self._per_address_slices.keys():
            if stamp < ten_ago:
                del self._per_address_slices[stamp] 
開發者ID:simplecrypto,項目名稱:powerpool,代碼行數:27,代碼來源:base.py

示例11: handle_request

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def handle_request(self, *args):
        try:
            super(GeventWorker, self).handle_request(*args)
        except gevent.GreenletExit:
            pass
        except SystemExit:
            pass 
開發者ID:jpush,項目名稱:jbox,代碼行數:9,代碼來源:ggevent.py

示例12: _poll_lookupd

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _poll_lookupd(self):
        try:
            delay = self.lookupd_poll_interval * self.lookupd_poll_jitter
            gevent.sleep(random.random() * delay)

            while True:
                gevent.sleep(self.lookupd_poll_interval)
                self.query_lookupd()

        except gevent.GreenletExit:
            pass 
開發者ID:wtolson,項目名稱:gnsq,代碼行數:13,代碼來源:consumer.py

示例13: _poll_ready

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _poll_ready(self):
        try:
            while True:
                if self._redistributed_ready_event.wait(5):
                    self._redistributed_ready_event.clear()
                self._redistribute_ready_state()

        except gevent.GreenletExit:
            pass 
開發者ID:wtolson,項目名稱:gnsq,代碼行數:11,代碼來源:consumer.py

示例14: _config_monitor

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _config_monitor(config_path):
    api_config_path = os.path.join(config_path, 'api')
    dirsnapshot = utils.DirSnapshot(api_config_path, CONFIG_FILES_RE)
    while True:
        try:
            with API_CONFIG_LOCK.acquire(timeout=600):
                new_snapshot = utils.DirSnapshot(api_config_path, CONFIG_FILES_RE)

                if new_snapshot != dirsnapshot:
                    try:
                        _load_config(config_path)
                        _load_auth_dbs(config_path)

                    except gevent.GreenletExit:
                        break

                    except:
                        LOG.exception('Error loading config')

                    dirsnapshot = new_snapshot

        except filelock.Timeout:
            LOG.error('Timeout locking config in config monitor')

        gevent.sleep(1)


# initialization 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:30,代碼來源:config.py

示例15: _retry_wrap

# 需要導入模塊: import gevent [as 別名]
# 或者: from gevent import GreenletExit [as 別名]
def _retry_wrap(self):
        while True:
            try:
                self._listen()

            except gevent.GreenletExit:
                break

            except:
                LOG.exception('Exception in event listener') 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:12,代碼來源:events.py


注:本文中的gevent.GreenletExit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。