本文整理汇总了Python中threading.Thread.name方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.name方法的具体用法?Python Thread.name怎么用?Python Thread.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processKeys
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def processKeys():
thread = None
killEvent = Event()
lastFlush = time.time()
kq = keyQueue()
thread = Thread(target=keyReader,args=(stdscr,kq,killEvent))
thread.name = 'keyboard-reader'
thread.start()
while(True):
try:
while (kq.size() == 0):
time.sleep(0.1)
now = time.time()
#queue up keys for 1 second before sending off since there
#is a lot of latency sending events across adb
if ((now - lastFlush) > 1):
while(kq.size() > 0):
#get the next block of keys of the same type (special or not)
isSpecial,vals = kq.getValsBlock()
if (isSpecial):
AdbUtils.adbSendSpecials(vals)
else:
AdbUtils.adbSendKeys(vals)
stdscr.refresh()
lastFlush = time.time()
except KeyboardInterrupt:
break
killEvent.set()
示例2: init_and_work
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def init_and_work(cls, mainFunction, event_handler = None):
"""
Inicia las estructuras para hacer el trabajo.
Se crea un hilo secundario que ejecuta el MainFunction con la función del
usuario mientras que el hilo principal ejecuta una aplicación Qt.
Se usa event_handler para sobreescribir el manejo de eventos globales en el
la función del hilo secundario (excepciones y en caso de salida)
"""
def work(mainFunction, event_handler):
"La función del hilo secundario"
res = 1
try:
res = mainFunction()
except Exception as ex: # Maneja las excepciones no manejadas
res = event_handler.handle_error(ex)
finally:
event_handler.on_end(res)
if event_handler == None:
event_handler = _DefaultHandler()
# setea el manejador de SIGINT
signal.signal(signal.SIGINT, signal.SIG_DFL)
# llama al hilo para empezar a correr
worker = Thread(target = work, args = (mainFunction, event_handler))
worker.name = "UserMainThread"
worker.start()
cls.__wait_for_framework_init()
示例3: manager
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def manager(rest_url = 'statuses/user_timeline'):
# print("manager: waiting tasks...")
# while tq.empty():
# time.sleep(1)
print("manager: start looping all keys, will quit when the main thread quit.")
while 1:
with open('./twitter_api_keys.pydict','r') as f:
api_keys = dict((key['consumer_key'], key) for key in eval(f.read()))
n = 0
for i, consumer_key in enumerate(api_keys):
time.sleep(1)
current_workers = list(t.name for t in enumerate_threads() if "Thread" not in t.name)
if consumer_key in current_workers or tq.qsize() < len(current_workers):
continue
worker = Thread(target = crawler,
kwargs ={'key': api_keys[consumer_key],
'name': '{min}:{max}-{no:>25}'.format(min = min(RG), max = max(RG), no = consumer_key),
'rest_url':rest_url})
worker.daemon = True
worker.name = consumer_key
worker.start()
n = n + 1
# print(("manager: {} workers are working.".format(len(current_workers))))
# if n>0: print(("manager: {} new workers are dispatched.".format(n)))
print("manager: quit.")
示例4: main
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def main():
threads = []
t = Thread(target=initTerm, args=(ctrlQueue,respQueue))
t.name = "User Command Loop"
threads.append(t)
t.start()
示例5: init_check_network_connection
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def init_check_network_connection(self):
t = Thread(target=self.check_network_connection, args=[False, 5, True])
t.name = 'RerequestCheckNetwork' + t.name
t.daemon = True
if DEBUG_LOCK or DEBUG_ANNOUNCE:
log(self.log_prefix + 'init_check_network_connection: start check_network_connection(): thread', t.name)
t.start()
示例6: fsinit
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def fsinit(self):
if self._use_cache:
t = Thread(target=self._cache_thread)
t.name = "cache loader"
t.daemon = True
t.start()
print "Ready"
示例7: add_thread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def add_thread(self, name, code, *args, **kwargs):
"""adds a thread to thread_list and starts it if none are running"""
thread = Thread(target=self.thread_run, args=(code,)+args, kwargs=kwargs)#, args=(self.loop_step, 10))
thread.name=name
self.thread_list.append(thread)
if self.thread is None:
self.start_thread()
示例8: start_locator_thread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def start_locator_thread(args):
api = PGoApi()
args.api = api
search_thread = Thread(target=search_loop, args=(args,))
search_thread.daemon = True
search_thread.name = 'search_thread'
search_thread.start()
示例9: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def __init__(self, nthreads):
"""
Inicializa el pipeline. Puede procesar hasta <nthreads> en paralelo
"""
if nthreads < 1:
raise ValueError("nthreads must be at least 1")
# Variables de sincronización
self.lock = Lock()
self.__events_queue = deque()
self.__events_queue_non_empty = Condition()
self.__items_queue = deque()
self.__finished = Condition()
# los hilos que están corriendo un item están en False, los otros están
# en True
self.__worker_threads = {
# libres
True: set([
_PipelineWorkerThread(i+1, self) for i in range(nthreads)
]),
# corriendo un item
False : set([])
}
# Inicia el hilo de control de pipeline
worker = Thread(target = ItemProcesorPipeline.__controller_thread_func,
args = (self, ) )
worker.name = "ItemProcesorPipeline-Main"
worker.daemon = True
worker.start()
示例10: start_locator_thread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def start_locator_thread(args):
search_thread = Thread(target=search_loop, args=(args,))
search_thread.daemon = True
search_thread.name = 'search_thread'
search_thread.start()
return search_thread
示例11: start_daemon_thread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def start_daemon_thread(target, name):
from threading import Thread
t = Thread(target=target)
t.name = name
t.daemon = True
t.start()
return t
示例12: rerequest_single
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def rerequest_single(self, t, s, params):
l = self.lock.set()
if t.startswith('udp'):
target = self._rerequest_single_udp
args = [t, params, l]
else:
target = self._rerequest_single
args = [t, s + get_key(t), l]
rq = Thread(target=target, args=args)
rq.name = 'TrackerRerequestB' + rq.name
rq.daemon = True
if DEBUG_LOCK or DEBUG_ANNOUNCE:
log(self.log_prefix + 'rerequest_single: start new thread: t', t, 'set_lock', l, 'thread', rq.name)
rq.start()
if DEBUG_LOCK:
log(self.log_prefix + 'rerequest_single: wait for lock: thread', currentThread().name)
self.lock.wait()
if DEBUG_LOCK or DEBUG_ANNOUNCE:
log(self.log_prefix + 'rerequest_single: wait for lock done: success', self.lock.success, 'thread', currentThread().name)
if self.lock.success:
self.lastsuccessful = t
self.last_failed = False
self.never_succeeded = False
return True
if not self.last_failed and self.lastsuccessful == t:
self.last_failed = True
self.lock.give_up()
return True
return False
示例13: cgminerThread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def cgminerThread():
pparams = PoolParams()
pparams.url = "http://notroll.in:6332"
pparams.username = "meard.1"
pparams.password = "12345"
global THREAD_INTENSITY_CHECKER
global THREAD_MINER
THREAD_INTENSITY_CHECKER = Thread(target=testIntensityAdjuster)
THREAD_MINER = Thread(target=startCGMINER, args=(pparams,)) #must be a tuple
THREAD_INTENSITY_CHECKER.name = "Intensity checker thread"
THREAD_MINER.name = "Miner control thread"
THREAD_MINER.start()
THREAD_INTENSITY_CHECKER.start()
示例14: _start_background_tasks
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def _start_background_tasks(self):
""" Start all background tasks. """
tasks = get_special_methods(self._plugin, 'background_task')
for task in tasks:
thread = Thread(target=PluginRuntime._run_background_task, args=(task,))
thread.name = 'Background thread ({0})'.format(task.__name__)
thread.daemon = True
thread.start()
示例15: init_server
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import name [as 别名]
def init_server(self, address):
self.server = Server(self)
self.server.rpc = self.rpc
self.server.start(address)
thread = Thread(target=self.server.serve_forever)
thread.name = 'ServerThread'
thread.daemon = True
thread.start()