python类activeCount()的实例源码

marketmaker.py 文件源码 项目:crypto-arbitrager 作者: artooze 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def new_order_notify(self, kexchange, type, maker_only=True, amount=None, price=None):
        order = super().new_order(kexchange, type, maker_only, amount, price)

        if order:
            # self.notify_msg(order['type'], order['price'])
            t = threading.Thread(target = self.notify_msg, args=(order['type'], order['price'],))
            t.start()
            logging.info("current has %d threads" % (threading.activeCount() - 1))
bitstar_mm.py 文件源码 项目:crypto-arbitrager 作者: artooze 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def new_order_notify(self, kexchange, type, maker_only=True, amount=None, price=None):
        order = super().new_order(kexchange, type, maker_only, amount, price)

        if order:
            # self.notify_msg(order['type'], order['price'])
            t = threading.Thread(target = self.notify_msg, args=(order['type'], order['price'],))
            t.start()
            logging.info("current has %d threads" % (threading.activeCount() - 1))
FNAScan1.bak.py 文件源码 项目:kekescan 作者: xiaoxiaoleo 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def t_join(m_count):
    tmp_count = 0
    i = 0
    while True:
        time.sleep(1)
        ac_count = threading.activeCount()
        if ac_count < m_count and ac_count == tmp_count:
            i+=1
        else:
            i = 0
        tmp_count = ac_count
        #print ac_count,queue.qsize()
        if (queue.empty() and threading.activeCount() <= 1) or i > 5:
            break
F-NAScan.kscan.py 文件源码 项目:kekescan 作者: xiaoxiaoleo 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def t_join(m_count):
    tmp_count = 0
    i = 0
    while True:
        time.sleep(2)
        ac_count = threading.activeCount()
        if ac_count < m_count and ac_count == tmp_count:
            i+=1
        else:
            i = 0
        tmp_count = ac_count
        #print ac_count,queue.qsize()
        if (queue.empty() and threading.activeCount() <= 1) or i > 5:
            break
FNAScan.py 文件源码 项目:kekescan 作者: xiaoxiaoleo 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def t_join(m_count):
    tmp_count = 0
    i = 0
    while True:
        time.sleep(1)
        ac_count = threading.activeCount()
        if ac_count < m_count and ac_count == tmp_count:
            i+=1
        else:
            i = 0
        tmp_count = ac_count
        #print ac_count,queue.qsize()
        if (queue.empty() and threading.activeCount() <= 1) or i > 5:
            break
test_threading.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_old_threading_api(self):
        # Just a quick sanity check to make sure the old method names are
        # still present
        t = threading.Thread()
        t.isDaemon()
        t.setDaemon(True)
        t.getName()
        t.setName("name")
        t.isAlive()
        e = threading.Event()
        e.isSet()
        threading.activeCount()
DataThreadModel.py 文件源码 项目:python_data_tools 作者: king3366ster 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def getActiveCount(self):
        return threading.activeCount() - 1
multiproc_download.py 文件源码 项目:pylibs 作者: tqlihuiqi 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def get(self):
        """ ???? """

        if self.readBytes < self.totalBytes:
            shards = range(self.totalBytes)

            os.mkdir(self.tempdir)

            for i in range(0, self.totalBytes, self.readBytes):
                point = shards[i: i + self.readBytes]
                headers = { "Range": "bytes=%s-%s" % (point[0], point[-1]) }
                filename = os.path.join(self.tempdir, str(point[-1]))

                thread = self.threadPool.get()
                t = thread(target=self.write_to_file, args=[filename, headers])
                t.start()

            while activeCount() > 1:
                time.sleep(1)

            results = sorted(map(int, os.listdir(self.tempdir)))

            with open(self.filename, "ab") as wfd:
                for result in results:
                    f = os.path.join(self.tempdir, str(result))

                    with open(f, "rb") as rfd:
                        content = True

                        while content:
                            content = rfd.read(1024)
                            wfd.write(content)

            self.delete_temp_dir()

        else:
            self.write_to_file(filename=self.filename, useThread=False)
example.py 文件源码 项目:libhoney-py 作者: honeycombio 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def num_threads():
    '''add information about the number of threads currently running to the
       event'''
    return threading.activeCount()


# run factorial. libh_builder comes with some fields already populated
# (namely, "version", "num_threads", and "range")
subprocess2.py 文件源码 项目:Chromium_DepotTools 作者: p07r0457 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def hack_subprocess():
  """subprocess functions may throw exceptions when used in multiple threads.

  See http://bugs.python.org/issue1731717 for more information.
  """
  global SUBPROCESS_CLEANUP_HACKED
  if not SUBPROCESS_CLEANUP_HACKED and threading.activeCount() != 1:
    # Only hack if there is ever multiple threads.
    # There is no point to leak with only one thread.
    subprocess._cleanup = lambda: None
    SUBPROCESS_CLEANUP_HACKED = True
subprocess2.py 文件源码 项目:node-gn 作者: Shouqun 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def hack_subprocess():
  """subprocess functions may throw exceptions when used in multiple threads.

  See http://bugs.python.org/issue1731717 for more information.
  """
  global SUBPROCESS_CLEANUP_HACKED
  if not SUBPROCESS_CLEANUP_HACKED and threading.activeCount() != 1:
    # Only hack if there is ever multiple threads.
    # There is no point to leak with only one thread.
    subprocess._cleanup = lambda: None
    SUBPROCESS_CLEANUP_HACKED = True
servers.py 文件源码 项目:sdk-samples 作者: cradlepoint 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _map_len(self):
            return threading.activeCount()
thread2.py 文件源码 项目:python_learn 作者: jetty-guo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def run(self):#????????????
        time.sleep(5)
        print "current has %d threads\r" % (threading.activeCount() - 1)
        print 'the arg thread is:%s\r' % self.arg
thread1.py 文件源码 项目:python_learn 作者: jetty-guo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self):#????????????
        time.sleep(5)
        print 'the arg thread is:%s\r' % self.arg
        print "current has %d threads" % (threading.activeCount() - 1)
sutime.py 文件源码 项目:python-sutime 作者: FraBle 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, jars=[], jvm_started=False, mark_time_ranges=False, include_range=False):
        """Initializes SUTime.
        """
        self.mark_time_ranges = mark_time_ranges
        self.include_range = include_range
        self.jars = jars
        self._is_loaded = False
        self._lock = threading.Lock()

        if not jvm_started:
            self._classpath = self._create_classpath()
            self._start_jvm()

        try:
            # make it thread-safe
            if threading.activeCount() > 1:
                if jpype.isThreadAttachedToJVM() is not 1:
                    jpype.attachThreadToJVM()
            self._lock.acquire()

            SUTimeWrapper = jpype.JClass(
                'edu.stanford.nlp.python.SUTimeWrapper')
            self._sutime = SUTimeWrapper(
                self.mark_time_ranges, self.include_range)
            self._is_loaded = True
        finally:
            self._lock.release()
subDomainsBrute.py 文件源码 项目:00scanner 作者: xiaoqin00 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _load_dns_servers(self):
        print '[+] Initializing, validate DNS servers ...'
        self.dns_servers = []
        # f=open('./dict/dns_servers.txt','a')
        with open('./dns_servers.txt') as f:
        # f=['114.114.114.114','114.114.115.115','180.76.76.76','223.5.5.5','223.6.6.6']
            for line in f:
                server = line.strip()
                if not server:
                    continue
                while True:
                    if threading.activeCount() < 50:
                        t = threading.Thread(target=self._test_server, args=(server,))
                        t.start()
                        break
                    else:
                        time.sleep(0.1)

        while threading.activeCount() > 2:
            time.sleep(0.1)
        self.dns_count = len(self.dns_servers)
        sys.stdout.write('\n')
        print '[+] Found %s available DNS Servers in total' % self.dns_count
        if self.dns_count == 0:
            print '[ERROR] No DNS Servers available.'
            self.STOP_ME = True
            sys.exit(-1)
sub_domains_brute.py 文件源码 项目:subDomainsBrute 作者: 0xa-saline 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _load_dns_servers(self):
        print('[+] Initializing, validate DNS servers ...')
        self.dns_servers = []
        thread_list = []
        # with open('dict/dns_servers.txt') as f:
        with open('api/dict/dns_servers.txt') as f:
            for line in f:
                server = line.strip()
                if not server:
                    continue
                while True:
                    if threading.activeCount() < 50:
                        t = threading.Thread(target=self._test_server, args=(server,))
                        t.setDaemon(True)
                        t.start()
                        thread_list.append(t)
                        break
                    else:
                        time.sleep(0.1)

        while True:
            flag_finished = True
            for i in thread_list:
                if i.isAlive():
                    flag_finished = False
            if flag_finished:
                break
            time.sleep(0.1)
        self.dns_count = len(self.dns_servers)
        sys.stdout.write('\n')
        print('[+] Found %s available DNS servers in total' % self.dns_count)
test_threading.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_old_threading_api(self):
        # Just a quick sanity check to make sure the old method names are
        # still present
        t = threading.Thread()
        t.isDaemon()
        t.setDaemon(True)
        t.getName()
        t.setName("name")
        t.isAlive()
        e = threading.Event()
        e.isSet()
        threading.activeCount()
__init__.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def tearDown(self):
        self.console.working = False
        self.console.wait_for_threads()
        sys.stdout.write("\tactive threads count : %s " % threading.activeCount())
#        sys.stderr.write("%s\n" % threading.enumerate())
Session.py 文件源码 项目:scraper 作者: ultraeric 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        """Runs the queue, goes through all of the actions and their recursive definitions."""

        threads = []
        for i in range(self.num_threads):
            threads.append(_Action_Queue_Thread(name = '_Action_Queue_Thread' + str(i), action_queue = self))
        for thread in threads:
            thread.start()
        print(threading.activeCount())  
        for thread in threads:
            thread.join()


问题


面经


文章

微信
公众号

扫码关注公众号