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


Python Thread.join方法代碼示例

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


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

示例1: load_library

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def load_library(libname):
# numpy 1.6 has bug in ctypeslib.load_library, see numpy/distutils/misc_util.py
    if '1.6' in numpy.__version__:
        if (sys.platform.startswith('linux') or
            sys.platform.startswith('gnukfreebsd')):
            so_ext = '.so'
        elif sys.platform.startswith('darwin'):
            so_ext = '.dylib'
        elif sys.platform.startswith('win'):
            so_ext = '.dll'
        else:
            raise OSError('Unknown platform')
        libname_so = libname + so_ext
        return ctypes.CDLL(os.path.join(os.path.dirname(__file__), libname_so))
    else:
        _loaderpath = os.path.dirname(__file__)
        return numpy.ctypeslib.load_library(libname, _loaderpath)

#Fixme, the standard resouce module gives wrong number when objects are released
#see http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/#fn:1
#or use slow functions as memory_profiler._get_memory did 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:23,代碼來源:misc.py

示例2: initial

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def initial(self, data):

        if self.terminate:

            #
            # - we're done, commit suicide
            # - the zk connection is guaranteed to be down at this point
            #
            self.exitcode()

        cnx_string = ','.join(self.brokers)
        data.zk = KazooClient(hosts=cnx_string, timeout=30.0, read_only=1, randomize_hosts=1)
        data.zk.add_listener(self.feedback)
        data.zk.start()

        return 'wait_for_cnx', data, 0 
開發者ID:autodesk-cloud,項目名稱:ochothon,代碼行數:18,代碼來源:io.py

示例3: decrypt_payload

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def decrypt_payload(encrypted_payload, key, nonce):
    """Decrypt payload."""
    aad = b"\x11"
    token = encrypted_payload[-4:]
    payload_counter = encrypted_payload[-7:-4]
    nonce = b"".join([nonce, payload_counter])
    cipherpayload = encrypted_payload[:-7]
    cipher = AES.new(key, AES.MODE_CCM, nonce=nonce, mac_len=4)
    cipher.update(aad)
    plaindata = None
    try:
        plaindata = cipher.decrypt_and_verify(cipherpayload, token)
    except ValueError as error:
        _LOGGER.error("Decryption failed: %s", error)
        _LOGGER.error("token: %s", token.hex())
        _LOGGER.error("nonce: %s", nonce.hex())
        _LOGGER.error("encrypted_payload: %s", encrypted_payload.hex())
        _LOGGER.error("cipherpayload: %s", cipherpayload.hex())
        return None
    return plaindata 
開發者ID:custom-components,項目名稱:sensor.mitemp_bt,代碼行數:22,代碼來源:sensor.py

示例4: run

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def run(self):

        try:
            #
            # - simply POST the control request to the pod
            # - any failure to reach the pod or timeout will be silently trapped (but the thread will
            #   join() with an empty code)
            #
            logger.debug('control -> %s' % self.url)
            reply = requests.post(self.url, data=json.dumps(self.js), timeout=self.timeout)
            self.code = reply.status_code
            logger.debug('control <- %s (HTTP %d)' % (self.url, self.code))

        except Timeout:

            #
            # - just log something
            # - the thread will simply return a None for return code
            #
            logger.debug('control <- %s (timeout)' % self.url) 
開發者ID:autodesk-cloud,項目名稱:ochopod,代碼行數:22,代碼來源:reactive.py

示例5: _get_info

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def _get_info(self, repoName, fullname):
        """Search for the respective package or module in the zipfile object"""
        parts = fullname.split('.')
        submodule = parts[-1]
        modulepath = '/'.join(parts)

        #check to see if that specific module exists

        for suffix, is_package in _search_order:
            relpath = modulepath + suffix
            try:
                moduleRepo[repoName].getinfo(relpath)
            except KeyError:
                pass
            else:
                return submodule, is_package, relpath

        #Error out if we can find the module/package
        msg = ('Unable to locate module %s in the %s repo' % (submodule, repoName))
        raise ZipImportError(msg) 
開發者ID:EmpireProject,項目名稱:EmPyre,代碼行數:22,代碼來源:agent.py

示例6: check_sanity

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def check_sanity(obj, keysref, stdout=sys.stdout):
    '''Check misinput of class attributes, check whether a class method is
    overwritten.  It does not check the attributes which are prefixed with
    "_".
    '''
    objkeys = [x for x in obj.__dict__ if not x.startswith('_')]
    keysub = set(objkeys) - set(keysref)
    if keysub:
        class_attr = set(dir(obj.__class__))
        keyin = keysub.intersection(class_attr)
        if keyin:
            msg = ('Overwritten attributes  %s  of %s\n' %
                   (' '.join(keyin), obj.__class__))
            if msg not in _warn_once_registry:
                _warn_once_registry[msg] = 1
                sys.stderr.write(msg)
                if stdout is not sys.stdout:
                    stdout.write(msg)
        keydiff = keysub - class_attr
        if keydiff:
            msg = ('%s does not have attributes  %s\n' %
                   (obj.__class__, ' '.join(keydiff)))
            if msg not in _warn_once_registry:
                _warn_once_registry[msg] = 1
                sys.stderr.write(msg)
                if stdout is not sys.stdout:
                    stdout.write(msg)
    return obj 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:30,代碼來源:misc.py

示例7: join

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def join(self):
        Process.join(self)
        if self._e is not None:
            raise ProcessRuntimeError('Error on process %s:\n%s' % (self, self._e))
        else:
            return self._q.get() 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:8,代碼來源:misc.py

示例8: __exit__

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def __exit__(self, type, value, traceback):
        for handler in self.handlers:
            if handler is not None:
                try:
                    if ThreadPoolExecutor is None:
                        handler.join()
                    else:
                        handler.result()
                except Exception as e:
                    raise ThreadRuntimeError('Error on thread %s:\n%s' % (self, e))

        if self.executor is not None:
            self.executor.shutdown(wait=True) 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:15,代碼來源:misc.py

示例9: int2bin

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def int2bin(n, count=24):  #10 -> binary
    """returns the binary of integer n, using count number of digits"""
    return "".join([str((n >> y) & 1) for y in range(count-1, -1, -1)]) 
開發者ID:quantumiracle,項目名稱:Reinforcement_Learning_for_Traffic_Light_Control,代碼行數:5,代碼來源:lights_cloud_test.py

示例10: join

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def join(self, *args):
        Thread.join(self, *args)
        return self._return 
開發者ID:quantumiracle,項目名稱:Reinforcement_Learning_for_Traffic_Light_Control,代碼行數:5,代碼來源:lights_cloud_test.py

示例11: join

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def join(self, timeout=None):
        if self.__useThreading:
            Thread.join(self, timeout) 
開發者ID:sprinkler,項目名稱:rainmachine-developer-resources,代碼行數:5,代碼來源:rmParserThread.py

示例12: stop

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def stop(self):
        """Stop the channel's event loop and join its thread.

        This calls :method:`Thread.join` and returns when the thread
        terminates. :class:`RuntimeError` will be raised if
        :method:`self.start` is called again.
        """
        self.join() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:channels.py

示例13: join

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def join(self):
        Thread.join(self)
        return self._return 
開發者ID:ina-foss,項目名稱:inaSpeechSegmenter,代碼行數:5,代碼來源:thread_returning.py

示例14: join

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def join(self, timeout=None):

        Thread.join(self)
        return self.out 
開發者ID:autodesk-cloud,項目名稱:ochothon,代碼行數:6,代碼來源:deploy.py

示例15: disconnect

# 需要導入模塊: from threading import Thread [as 別名]
# 或者: from threading.Thread import join [as 別名]
def disconnect(self):
        """Disconnect from the websocket and join thread."""
        super(WebSocketConnectorThread, self).disconnect()
        Thread.join(self, timeout=1) 
開發者ID:Crypto-toolbox,項目名稱:hitbtc,代碼行數:6,代碼來源:wss.py


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