本文整理汇总了Python中thread._count函数的典型用法代码示例。如果您正苦于以下问题:Python _count函数的具体用法?Python _count怎么用?Python _count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_count函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_class
def setup_class(cls):
GenericTestThread.setup_class.im_func(cls)
# if we cannot start more than, say, 1000 threads on this OS, then
# we can check that we get the proper error at app-level
space = cls.space
lock = thread.allocate_lock()
lock.acquire()
def f():
lock.acquire()
lock.release()
start = thread._count()
try:
try:
for i in range(1000):
thread.start_new_thread(f, ())
finally:
lock.release()
except (thread.error, MemoryError):
cls.w_can_start_many_threads = space.wrap(False)
else:
cls.w_can_start_many_threads = space.wrap(True)
# wait a bit to allow all threads to finish now
remaining = thread._count()
retries = 0
while remaining > start:
retries += 1
if retries == 200:
raise Exception("the test's threads don't stop!")
time.sleep(0.2)
remaining = thread._count()
示例2: test_thread_count
def test_thread_count(self):
import thread, time
feedback = []
please_start = []
def f():
feedback.append(42)
self.waitfor(lambda: please_start)
assert thread._count() == 0
thread.start_new_thread(f, ())
self.waitfor(lambda: feedback)
assert thread._count() == 1
please_start.append(1) # trigger
示例3: threading_cleanup
def threading_cleanup(nb_threads):
_MAX_COUNT = 10
for count in range(_MAX_COUNT):
n = thread._count()
if n == nb_threads:
break
time.sleep(0.1)
示例4: run2
def run2():
global state
print lock.acquire(0)
print "num threads:", _count()
state = 1
print lock.acquire()
lock.release()
state = 2
示例5: monitor
def monitor():
global PASSWORD_DIC, THREAD_COUNT, TIMEOUT, WHITE_LIST
while True:
queue_count = na_task.find({"status": 0, "plan": 0}).count()
if queue_count:
load = 1
else:
ac_count = thread._count()
load = float(ac_count - 4) / THREAD_COUNT
if load > 1: load = 1
if load < 0: load = 0
na_heart.update({"name": "load"}, {"$set": {"value": load, "up_time": datetime.datetime.now()}})
PASSWORD_DIC, THREAD_COUNT, TIMEOUT, WHITE_LIST = get_config()
if load > 0:
time.sleep(8)
else:
time.sleep(60)
示例6: init
plugin_info['add_time'] = time_
plugin_info['filename'] = plugin_name
plugin_info['count'] = 0
del plugin_info['plugin']
na_plugin.insert(plugin_info)
except:
pass
if __name__ == '__main__':
init()
PASSWORD_DIC, THREAD_COUNT, TIMEOUT, WHITE_LIST = get_config()
thread.start_new_thread(monitor, ())
while True:
task_id, task_plan, task_target, task_plugin = queue_get()
if task_id == '':
time.sleep(10)
continue
if PLUGIN_DB:
del sys.modules[PLUGIN_DB.keys()[0]] # 清理插件缓存
PLUGIN_DB.clear()
for task_netloc in task_target:
while True:
if int(thread._count()) < THREAD_COUNT:
if task_netloc[0] in WHITE_LIST: break
thread.start_new_thread(vulscan, (task_id, task_netloc, task_plugin))
break
else:
time.sleep(2)
if task_plan == 0: na_task.update({"_id": task_id}, {"$set": {"status": 2}})
示例7: threading_setup
def threading_setup():
if thread:
return thread._count(),
else:
return 1,
示例8: syscall
import thread, os, time
#thread.start_new_thread
def syscall(cmd, crap=None):
os.system(cmd)
#run transition models
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py x_axis',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py y_axis',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py center',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py shape',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py spread',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py h_to_d',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py d_to_h',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff-gauss_L1.py histogram',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py x_axis',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py y_axis',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py center',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py shape',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py spread',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py h_to_d',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py d_to_h',0) )
thread.start_new_thread(syscall,('python run_LFKT-trans-diff_L1.py histogram',0) )
time.sleep(10)
print "ASDFASDGASDFGASDFG"
print thread._count()
示例9: ins
#!/usr/bin/python
import os,commands,time,socket,thread
def ins(ip):
#print "chup rh betichod"
installed=commands.getstatusoutput("sshpass -p darwin ssh {} 'rpm -q sshpass'".format(ip))
if installed[0]!=0:
s=commands.getstatusoutput("sshpass -p darwin scp hadoop1/Initiation/sp.rpm [email protected]{}:/tmp/ ".format(ip))
#print(s)
s=commands.getstatusoutput("sshpass -p darwin ssh {} 'rpm -ivh /tmp/sp.rpm' ".format(ip))
#print s
#listscan=['192.168.43.198','192.168.43.104']
for each in listscan:
#print each
s=commands.getstatusoutput("ping -c 1 {}".format(each))
#print(s[0])
thread.start_new_thread(ins,(each,))
#print thread._count()
while thread._count()!=0:
time.sleep(3)
print "installer ended"
示例10: run
def run(arg):
global done
with print_lock:
print "num threads:", _count()
print "in other thread!", arg
done = 1
示例11: type
print type(allocate_lock())
print_lock = allocate_lock()
done = 0
def run(arg):
global done
with print_lock:
print "num threads:", _count()
print "in other thread!", arg
done = 1
print "starting!"
print "num threads:", _count()
with print_lock:
t = start_new_thread(run, (5,))
print type(t)
while not done:
time.sleep(0)
print "done!"
print "num threads:", _count()
done = False
with print_lock:
t = start_new_thread(run, (), {'arg': 6})
while not done:
time.sleep(0)
示例12: print_time
def print_time( threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print "%s(%s): %s" % ( threadName, thread._count(), time.ctime(time.time()) )
示例13: threading_setup
def threading_setup():
return thread._count(),