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


Python coros.RLock方法代码示例

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


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

示例1: __new__

# 需要导入模块: from gevent import coros [as 别名]
# 或者: from gevent.coros import RLock [as 别名]
def __new__(cls, *args, **kw):
        self = object.__new__(cls)
        object.__setattr__(self, '_local__args', (args, kw))
        object.__setattr__(self, '_local__lock', RLock())
        dicts = WeakKeyDictionary()
        object.__setattr__(self, '_local__dicts', dicts)

        if (args or kw) and (cls.__init__ is object.__init__):
            raise TypeError("Initialization arguments are not supported")

        # We need to create the greenlet dict in anticipation of
        # __init__ being called, to make sure we don't call it again ourselves.
        dict = object.__getattribute__(self, '__dict__')
        dicts[getcurrent()] = dict
        return self 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:17,代码来源:local.py

示例2: rlock_object

# 需要导入模块: from gevent import coros [as 别名]
# 或者: from gevent.coros import RLock [as 别名]
def rlock_object(self):
        """Create an appropriate RLock object"""
        return RLock() 
开发者ID:sunqb,项目名称:oa_qian,代码行数:5,代码来源:gevent.py

示例3: __init__

# 需要导入模块: from gevent import coros [as 别名]
# 或者: from gevent.coros import RLock [as 别名]
def __init__(self, fileserver_ip=None, fileserver_port=None):
        self.privatekeys = {}  # Onion: Privatekey
        self.site_onions = {}  # Site address: Onion
        self.tor_exe = "tools/tor/tor.exe"
        self.tor_process = None
        self.log = logging.getLogger("TorManager")
        self.start_onions = None
        self.conn = None
        self.lock = RLock()

        if config.tor == "disable":
            self.enabled = False
            self.start_onions = False
            self.status = "Disabled"
        else:
            self.enabled = True
            self.status = "Waiting"

        if fileserver_port:
            self.fileserver_port = fileserver_port
        else:
            self.fileserver_port = config.fileserver_port

        self.ip, self.port = config.tor_controller.split(":")
        self.port = int(self.port)

        self.proxy_ip, self.proxy_port = config.tor_proxy.split(":")
        self.proxy_port = int(self.proxy_port)

        # Test proxy port
        if config.tor != "disable":
            try:
                assert self.connect(), "No connection"
                self.log.debug("Tor proxy port %s check ok" % config.tor_proxy)
            except Exception, err:
                self.log.debug("Tor proxy port %s check error: %s" % (config.tor_proxy, err))
                self.enabled = False
                # Change to self-bundled Tor ports
                from lib.PySocks import socks
                self.port = 49051
                self.proxy_port = 49050
                socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", self.proxy_port)
                if os.path.isfile(self.tor_exe):  # Already, downloaded: sync mode
                    self.startTor()
                else:  # Not downloaded yet: Async mode
                    gevent.spawn(self.startTor) 
开发者ID:bashrc,项目名称:zeronet-debian,代码行数:48,代码来源:TorManager.py

示例4: __init__

# 需要导入模块: from gevent import coros [as 别名]
# 或者: from gevent.coros import RLock [as 别名]
def __init__(self, filter="ALL", eventjson=True, pool_size=5000, trace=False):
        self._is_eventjson = eventjson
        # Callbacks for reading events and sending responses.
        self._response_callbacks = {'api/response':self._api_response,
                                    'command/reply':self._command_reply,
                                    'text/disconnect-notice':self._disconnect_notice,
                                    'text/event-json':self._event_json,
                                    'text/event-plain':self._event_plain
                                   }
        # Closing state flag
        self._closing_state = False
        # Default event filter.
        self._filter = filter
        # Commands pool list
        self._commands_pool = []
        # Lock to force eventsocket commands to be sequential.
        self._lock = RLock()
        # Sets connected to False.
        self.connected = False
        # Sets greenlet handler to None
        self._g_handler = None
        # Build events callbacks dict
        self._event_callbacks = {}
        for meth in dir(self):
            if meth[:3] == 'on_':
                event_name = meth[3:].upper()
                func = getattr(self, meth, None)
                if func:
                    self._event_callbacks[event_name] = func
        unbound = getattr(self, 'unbound_event', None)
        self._event_callbacks['unbound_event'] = unbound
        # Set greenlet spawner
        if pool_size > 0:
            self.pool = gevent.pool.Pool(pool_size)
            self._spawn = self.pool.spawn
        else:
            self._spawn = gevent.spawn_raw
        # set tracer
        try:
            logger = self.log
        except AttributeError:
            logger = None
        if logger and trace is True:
            self.trace = self._trace
        else:
            self.trace = self._notrace 
开发者ID:JoneXiong,项目名称:YouPBX,代码行数:48,代码来源:eventsocket.py


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