本文整理汇总了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
示例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
示例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
示例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)
示例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)
示例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
示例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()
示例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)
示例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)
示例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()
示例13: join
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import join [as 别名]
def join(self):
Thread.join(self)
return self._return
示例14: join
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import join [as 别名]
def join(self, timeout=None):
Thread.join(self)
return self.out
示例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)