Python threading._RLock() Examples

The following are code examples for showing how to use threading._RLock(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: hostapd-mana   Author: adde88   File: threadable.py    (license) View Source Project 6 votes vote down vote up
def init(with_threads=1):
    """Initialize threading.

    Don't bother calling this.  If it needs to happen, it will happen.
    """
    global threaded, _synchLockCreator, XLock

    if with_threads:
        if not threaded:
            if threadmodule is not None:
                threaded = True

                class XLock(threadingmodule._RLock, object):
                    def __reduce__(self):
                        return (unpickle_lock, ())

                _synchLockCreator = XLock()
            else:
                raise RuntimeError("Cannot initialize threading, platform lacks thread support")
    else:
        if threaded:
            raise RuntimeError("Cannot uninitialize threads")
        else:
            pass 
Example 2
Project: sslstrip-hsts-openwrt   Author: adde88   File: threadable.py    (license) View Source Project 6 votes vote down vote up
def init(with_threads=1):
    """Initialize threading.

    Don't bother calling this.  If it needs to happen, it will happen.
    """
    global threaded, _synchLockCreator, XLock

    if with_threads:
        if not threaded:
            if threadmodule is not None:
                threaded = True

                class XLock(threadingmodule._RLock, object):
                    def __reduce__(self):
                        return (unpickle_lock, ())

                _synchLockCreator = XLock()
            else:
                raise RuntimeError("Cannot initialize threading, platform lacks thread support")
    else:
        if threaded:
            raise RuntimeError("Cannot uninitialize threads")
        else:
            pass 
Example 3
Project: zenchmarks   Author: squeaky-pl   File: threadable.py    (license) View Source Project 6 votes vote down vote up
def init(with_threads=1):
    """Initialize threading.

    Don't bother calling this.  If it needs to happen, it will happen.
    """
    global threaded, _synchLockCreator, XLock

    if with_threads:
        if not threaded:
            if threadingmodule is not None:
                threaded = True

                class XLock(threadingmodule._RLock, object):
                    def __reduce__(self):
                        return (unpickle_lock, ())

                _synchLockCreator = XLock()
            else:
                raise RuntimeError("Cannot initialize threading, platform lacks thread support")
    else:
        if threaded:
            raise RuntimeError("Cannot uninitialize threads")
        else:
            pass 
Example 4
Project: hostapd-mana   Author: adde88   File: compat.py    (license) View Source Project 5 votes vote down vote up
def __init__(self, *args):
            from OpenSSL import SSL as _ssl
            self._ssl_conn = apply(_ssl.Connection, args)
            from threading import _RLock
            self._lock = _RLock() 
Example 5
Project: sslstrip-hsts-openwrt   Author: adde88   File: compat.py    (license) View Source Project 5 votes vote down vote up
def __init__(self, *args):
            from OpenSSL import SSL as _ssl
            self._ssl_conn = apply(_ssl.Connection, args)
            from threading import _RLock
            self._lock = _RLock() 
Example 6
Project: solaris-ips   Author: oracle   File: nrlock.py    (license) View Source Project 5 votes vote down vote up
def __init__(self):
                threading._RLock.__init__(self) 
Example 7
Project: solaris-ips   Author: oracle   File: nrlock.py    (license) View Source Project 5 votes vote down vote up
def acquire(self, blocking=1):
                if self._is_owned():
                        raise NRLockException("Recursive NRLock acquire")
                return threading._RLock.acquire(self, blocking) 
Example 8
Project: solaris-ips   Author: oracle   File: nrlock.py    (license) View Source Project 5 votes vote down vote up
def release(self):
                try:
                        threading._RLock.release(self)
                except RuntimeError:
                        errbuf = "Release of unacquired lock\n"
                        errbuf += self._debug_lock_release()
                        raise NRLockException(errbuf)