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


Python Greenlet.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, target=''):
        Greenlet.__init__(self)
        self.target=target
        r=requests.get(target)
        self.headers=r.headers
        self.content=r.content

        gevent.spawn(self.loadplugins).join()

        gevent.joinall([
            gevent.spawn(self.runplugin, '1'),
            gevent.spawn(self.runplugin, '2'),
            gevent.spawn(self.runplugin, '3'),
            gevent.spawn(self.runplugin, '4'),
            gevent.spawn(self.runplugin, '5'),
            gevent.spawn(self.runplugin, '6'),
            gevent.spawn(self.runplugin, '7'),
            gevent.spawn(self.runplugin, '8'),
            gevent.spawn(self.runplugin, '9'),
            gevent.spawn(self.runplugin, '10'),

        ]) 
开发者ID:cflq3,项目名称:getcms,代码行数:24,代码来源:web_finder.py

示例2: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, job_info, core_context, parent=None, args=None,
                 kwargs=None):
        if args is None:
            args = tuple()
        if kwargs is None:
            kwargs = dict()

        self._job_info = job_info
        self._scope = {}
        self._core = core_context
        self._job_engine = core_context.lookup(ENGINE_NAME)
        self._task_engine = get_task_engine()
        self._scope['ava'] = self
        self._scope['parent'] = parent
        self._scope['args'] = args
        self._scope['kwargs'] = kwargs
        self._scope['do'] = ActionDoer(self._task_engine, job_info.id)

        jobhelper.populate_scope(self._scope)

        self.exception = None
        self.result = None 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:24,代码来源:engine.py

示例3: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, account_id, namespace_id, email_address, folder_id,
                 folder_name, provider_name, poll_frequency=1,
                 scope=None):

        self.account_id = account_id
        self.namespace_id = namespace_id
        self.provider_name = provider_name
        self.poll_frequency = poll_frequency
        self.scope = scope

        self.log = logger.new(account_id=account_id)

        self.shutdown = event.Event()
        self.heartbeat_status = HeartbeatStatusProxy(self.account_id,
                                                     folder_id,
                                                     folder_name,
                                                     email_address,
                                                     provider_name)
        Greenlet.__init__(self) 
开发者ID:nylas,项目名称:sync-engine,代码行数:21,代码来源:base_sync.py

示例4: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, seconds):
    Greenlet.__init__(self)
    self.seconds = seconds 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:5,代码来源:greenlet.py

示例5: _partition_node

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def _partition_node(node):
    """Split a host:port string returned from mongod/s into
    a (host, int(port)) pair needed for socket.connect().
    """
    host = node
    port = 27017
    idx = node.rfind(':')
    if idx != -1:
        host, port = node[:idx], int(node[idx + 1:])
    if host.startswith('['):
        host = host[1:-1]
    return host, port


# Concurrency notes: A MongoReplicaSetClient keeps its view of the replica-set
# state in an RSState instance. RSStates are immutable, except for
# host-pinning. Pools, which are internally thread / greenlet safe, can be
# copied from old to new RSStates safely. The client updates its view of the
# set's state not by modifying its RSState but by replacing it with an updated
# copy.

# In __init__, MongoReplicaSetClient gets a list of potential members called
# 'seeds' from its initial parameters, and calls refresh(). refresh() iterates
# over the the seeds in arbitrary order looking for a member it can connect to.
# Once it finds one, it calls 'ismaster' and sets self.__hosts to the list of
# members in the response, and connects to the rest of the members. refresh()
# sets the MongoReplicaSetClient's RSState. Finally, __init__ launches the
# replica-set monitor.

# The monitor calls refresh() every 30 seconds, or whenever the client has
# encountered an error that prompts it to wake the monitor.

# Every method that accesses the RSState multiple times within the method makes
# a local reference first and uses that throughout, so it's isolated from a
# concurrent method replacing the RSState with an updated copy. This technique
# avoids the need to lock around accesses to the RSState. 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:38,代码来源:mongo_replica_set_client.py

示例6: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(
            self, threadlocal, hosts=None, host_to_member=None, arbiters=None,
            writer=None, error_message='No primary available', exc=None,
            initial=False):
        """An immutable snapshot of the client's view of the replica set state.

        Stores Member instances for all members we're connected to, and a
        list of (host, port) pairs for all the hosts and arbiters listed
        in the most recent ismaster response.

        :Parameters:
          - `threadlocal`: Thread- or greenlet-local storage
          - `hosts`: Sequence of (host, port) pairs
          - `host_to_member`: Optional dict: (host, port) -> Member instance
          - `arbiters`: Optional sequence of arbiters as (host, port)
          - `writer`: Optional (host, port) of primary
          - `error_message`: Optional error if `writer` is None
          - `exc`: Optional error if state is unusable
          - `initial`: Whether this is the initial client state
        """
        self._threadlocal = threadlocal  # threading.local or gevent local
        self._arbiters = frozenset(arbiters or [])  # set of (host, port)
        self._writer = writer  # (host, port) of the primary, or None
        self._error_message = error_message
        self._host_to_member = host_to_member or {}
        self._hosts = frozenset(hosts or [])
        self._members = frozenset(list(self._host_to_member.values()))
        self._exc = exc
        self._initial = initial
        self._primary_member = self.get(writer) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:mongo_replica_set_client.py

示例7: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, config):
        try:
            f = open(config['certFilename'], 'rb')
            self.certs = pickle.load(f)
            f.close()
        except IOError:
            self.certs = {}
        self.config = config
        self.lock = Lock() 
开发者ID:lehui99,项目名称:schcp,代码行数:11,代码来源:scphcp.py

示例8: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, app):
        Greenlet.__init__(self)
        self.is_stopped = False
        self.app = app
        self.config = utils.update_config_with_defaults(app.config, self.default_config)
        available_service = [s.__class__ for s in self.app.services.values()]
        for r in self.required_services:
            assert r in available_service, (r, available_service) 
开发者ID:heikoheiko,项目名称:pydevp2p,代码行数:10,代码来源:service.py

示例9: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, run=None, *args, **kwargs):
    self.name = None
    Greenlet.__init__(self, run, *args, **kwargs) 
开发者ID:steveniemitz,项目名称:scales,代码行数:5,代码来源:asynchronous.py

示例10: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, addr, *args, **kwargs):
        if self.__class__.__instance is not None:
            raise RuntimeError(
                'only one backdoor server allowed to be running'
            )
        self.addr = addr
        self.server = BackdoorServer(addr)
        Greenlet.__init__(self, *args, **kwargs) 
开发者ID:huskar-org,项目名称:huskar,代码行数:10,代码来源:backdoor.py

示例11: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, config, socksProxy):
        self.config = config
        if type(socksProxy) == int:
            self.host = config['defaultSocksHost']
            self.port = socksProxy
        else:
            self.host = socksProxy[0]
            self.port = socksProxy[1]
        self.failCount = 0
        self.fail = False 
开发者ID:lehui99,项目名称:gipt,代码行数:12,代码来源:gipt.py

示例12: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, poll_interval=30, chunk_size=DOC_UPLOAD_CHUNK_SIZE):
        self.poll_interval = poll_interval
        self.chunk_size = chunk_size
        self.transaction_pointers = {}

        self.log = log.new(component='contact-search-index')
        Greenlet.__init__(self) 
开发者ID:nylas,项目名称:sync-engine,代码行数:9,代码来源:search.py

示例13: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, account, heartbeat=1):
        bind_context(self, 'mailsyncmonitor', account.id)
        self.shutdown = event.Event()
        # how often to check inbox, in seconds
        self.heartbeat = heartbeat
        self.log = log.new(component='mail sync', account_id=account.id)
        self.account_id = account.id
        self.namespace_id = account.namespace.id
        self.email_address = account.email_address
        self.provider_name = account.verbose_provider

        Greenlet.__init__(self) 
开发者ID:nylas,项目名称:sync-engine,代码行数:14,代码来源:base.py

示例14: __init__

# 需要导入模块: from gevent import Greenlet [as 别名]
# 或者: from gevent.Greenlet import __init__ [as 别名]
def __init__(self, account_id, namespace_id, folder_name,
                 email_address, provider_name, syncmanager_lock):

        with session_scope(namespace_id) as db_session:
            try:
                folder = db_session.query(Folder). \
                    filter(Folder.name == folder_name,
                           Folder.account_id == account_id).one()
            except NoResultFound:
                raise MailsyncError(u"Missing Folder '{}' on account {}"
                                    .format(folder_name, account_id))

            self.folder_id = folder.id
            self.folder_role = folder.canonical_name
            # Metric flags for sync performance
            self.is_initial_sync = folder.initial_sync_end is None
            self.is_first_sync = folder.initial_sync_start is None
            self.is_first_message = self.is_first_sync

        bind_context(self, 'foldersyncengine', account_id, self.folder_id)
        self.account_id = account_id
        self.namespace_id = namespace_id
        self.folder_name = folder_name
        self.email_address = email_address

        if self.folder_name.lower() == 'inbox':
            self.poll_frequency = INBOX_POLL_FREQUENCY
        else:
            self.poll_frequency = DEFAULT_POLL_FREQUENCY
        self.syncmanager_lock = syncmanager_lock
        self.state = None
        self.provider_name = provider_name
        self.last_fast_refresh = None
        self.flags_fetch_results = {}
        self.conn_pool = connection_pool(self.account_id)

        self.state_handlers = {
            'initial': self.initial_sync,
            'initial uidinvalid': self.resync_uids,
            'poll': self.poll,
            'poll uidinvalid': self.resync_uids,
        }

        self.setup_heartbeats()
        Greenlet.__init__(self)

        # Some generic IMAP servers are throwing UIDVALIDITY
        # errors forever. Instead of resyncing those servers
        # ad vitam, we keep track of the number of consecutive
        # times we got such an error and bail out if it's higher than
        # MAX_UIDINVALID_RESYNCS.
        self.uidinvalid_count = 0 
开发者ID:nylas,项目名称:sync-engine,代码行数:54,代码来源:generic.py


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