• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python thread.start_new函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中thread.start_new函数的典型用法代码示例。如果您正苦于以下问题:Python start_new函数的具体用法?Python start_new怎么用?Python start_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了start_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: init_pipe

def init_pipe():
    try:
        thread.start_new(socket_output_thread, ())
        thread.start_new(socket_input_thread,())
    except:
        print "Could nor start pipe thread ...."
        exit()  
开发者ID:weihuantsao,项目名称:relay_pi,代码行数:7,代码来源:ctl.py


示例2: dispecher

 def dispecher(self):
     """receiving clients and their distribution in the processing flow"""
     while True:
         connection, address = self._sockobj.accept()
         print('server connected by', address)
         print('at', self.now())
         thread.start_new(self.handleClient, (connection, address,))
开发者ID:Pir-4,项目名称:forensic_modul,代码行数:7,代码来源:server.py


示例3: run

	def run(self, nworkers):
		if not self.work:
			return # Nothing to do
		for i in range(nworkers-1):
			thread.start_new(self._worker, ())
		self._worker()
		self.todo.acquire()
开发者ID:asottile,项目名称:ancient-pythons,代码行数:7,代码来源:find.py


示例4: test_wait

    def test_wait(self):
        for i in range(NUM_THREADS):
            thread.start_new(self.f, (i,))

        time.sleep(LONGSLEEP)

        a = self.alive.keys()
        a.sort()
        self.assertEquals(a, range(NUM_THREADS))

        prefork_lives = self.alive.copy()

        if sys.platform in ['unixware7']:
            cpid = os.fork1()
        else:
            cpid = os.fork()

        if cpid == 0:
            # Child
            time.sleep(LONGSLEEP)
            n = 0
            for key in self.alive:
                if self.alive[key] != prefork_lives[key]:
                    n += 1
            os._exit(n)
        else:
            # Parent
            self.wait_impl(cpid)
            # Tell threads to die
            self.stop = 1
            time.sleep(2*SHORTSLEEP) # Wait for threads to die
开发者ID:1310701102,项目名称:sl4a,代码行数:31,代码来源:fork_wait.py


示例5: start

    def start(self):
        """Start the uber basic interface.

        All request are handled by BasicWeb method handle_request.

        """

        def make_handler(parent):
            class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
                # A super-simple HTTP request handler:
                def do_GET(self):
                    parent.handle_request("GET", self)

                def do_POST(self):
                    parent.handle_request("POST", self)

                def do_PUT(self):
                    parent.handle_request("PUT", self)

                def do_DELETE(self):
                    parent.handle_request("DELETE", self)

                def do_HEAD(self):
                    parent.handle_request("HEAD", self)

            return RequestHandler

        self.log.info("Creating FakeWebServer.")
        self.server = StoppableTCPServer((self.interface, self.port), make_handler(self))

        def _start(data=0):
            self.log.info("start: URI<%s>" % self.uri)
            self.server.serve_forever()

        thread.start_new(_start, (0,))
开发者ID:oisinmulvihill,项目名称:evasion-common,代码行数:35,代码来源:webhelpers.py


示例6: __init__

	def __init__(self, bot, config):
		self.bot = bot
		self.config = config
		self.about = "Eggdropbot allows sleekbots to run Eggdrop IRC (TCL) scripts, providing the (currently partial) Eggdrop API re-implemented for XMPP MUC.\nWritten By: Kevin Smith"
		self.bot.addIMCommand('eggdrop', self.handle_eggdrop)
		self.bot.addMUCCommand('eggdrop', self.handle_eggdrop)
		self.bot.addHelp('eggdrop', 'Eggdrop control command', "Configure eggdrop compatability support.", 'eggdrop [args]')
		self.bot.add_event_handler("message", self.handle_message_event, threaded=True)
		self.bot.add_event_handler("groupchat_message", self.handle_muc_event, threaded=True)
		# queue of outgoing TCL
		self.queue = Queue.Queue()
		# list of incoming messages from tcl
		self.messageQueue = []
		#self.queueExec('puts "bert"')
		#TCL support scripts - these are the TCL side of the eggdrop emulation
		self.queueExec('source "plugins/eggdrop/support.tcl"')
		self.queueExec('source "plugins/eggdrop/eggdropcompat.tcl"')
		#load the user-specified eggdrop scripts
		scripts = self.config.findall('script')
		if scripts:
			for script in scripts:
				logging.info("eggdropbot.py loading script %s." % script.attrib['file'])
				self.queueExec('source "scripts/' + script.attrib['file'] + '"')
		
		thread.start_new(self.loop,())
开发者ID:Kev,项目名称:SleekBot,代码行数:25,代码来源:eggdropbot.py


示例7: run

def run():
    try:
        insert_iptables_rules()
        thread.start_new(handle_nfqueue, ())
    except:
        LOGGER.exception('failed to start dns service')
        dns_service_status.error = traceback.format_exc()
开发者ID:jieah,项目名称:fqrouter,代码行数:7,代码来源:dns_service.py


示例8: applyFunctionToNFrames

def applyFunctionToNFrames(func, filesPerThread, nframes, conversionargs):
    if(nframes < filesPerThread):
        func(0, 0, nframes, conversionargs)
    else:
        try:
            import thread
            keepSpawning = 1
            start = filesPerThread
            end = filesPerThread
            threadID = 1
            # Create a mutex array
            numThreads = nframes / filesPerThread
            if(numThreads * filesPerThread < nframes):
                numThreads = numThreads + 1
            exitmutex = [0] * numThreads
            while keepSpawning == 1:
                end = end + filesPerThread
                if(end >= nframes):
                    end = nframes
                    keepSpawning = 0
                thread.start_new(applyFunctionToNFramesWMutex, (threadID, exitmutex, func, start, end, conversionargs))
                start = start + filesPerThread
                threadID = threadID + 1
            # Do the first part of the work on the main thread.
            applyFunctionToNFramesWMutex(0, exitmutex, func, 0, filesPerThread, conversionargs)

            # Wait for all of the threads to complete
            while 0 in exitmutex: pass
        except ImportError:
            print "Could not import threads module."
            func(0, 0, nframes, conversionargs)
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:31,代码来源:movietools.py


示例9: pressStart

 def pressStart(self):
     '''
     Function triggered by clicking 'START' button.
     It will start a new thread to simulate the streaming fashion.
     '''
     thread.start_new(self.runForever, ());
     self.start_btn['state'] = Tkinter.DISABLED;
开发者ID:FredYao,项目名称:Dynamic-Graph-Visualization,代码行数:7,代码来源:CitationStream.py


示例10: __init__

 def __init__(self, bot, config):
     self.bot = bot
     self.config = config
     self.about = "Attempts to keep Sleek in muc channels."
     self.shuttingDown = False
     thread.start_new(self.loop, ())
     self.bot.add_handler("<message xmlns='jabber:client' type='error'><error type='modify' code='406' ><not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></message>", self.handle_message_error)
开发者ID:Kev,项目名称:SleekBot,代码行数:7,代码来源:muc_stability.py


示例11: test_fork

    def test_fork(self):
        # XXX This test depends on a multicore machine, as busy_thread must
        # aquire the GIL the instant that the main thread releases it.
        # It will incorrectly pass if the GIL is not grabbed in time.
        import thread
        import os
        import time

        if not hasattr(os, 'fork'):
            skip("No fork on this platform")

        run = True
        done = []
        def busy_thread():
            while run:
                time.sleep(0)
            done.append(None)

        try:
            thread.start_new(busy_thread, ())

            pid = os.fork()

            if pid == 0:
                os._exit(0)

            else:
                time.sleep(1)
                spid, status = os.waitpid(pid, os.WNOHANG)
                assert spid == pid
        finally:
            run = False
            self.waitfor(lambda: done)
开发者ID:alkorzt,项目名称:pypy,代码行数:33,代码来源:test_fork.py


示例12: resolveFakeDimensions

   def resolveFakeDimensions (self, task):      
      netCdfObject = GmiNetCdfFileTools ()

      print "about to start threads for resolving dimensions..."

      exitMutexes = []
      count = 0
      for prefix in self.PREFIXES:
         for resolution in ["2x2.5", "1x1.25", "0.625x0.5"]:
            fileName = self.basePath + prefix  + self.endPath + "." + resolution + ".nc"
            if not os.path.exists (fileName): raise fileName + " does not exist! ERROR"

            # for each file type fix the fake dimensions
            exitMutexes.append (thread.allocate_lock())
            thread.start_new (netCdfObject.resolveFieldDimensions, \
                (fileName, count, self.GEOS5FIELDS, ['time', 'lat', 'lon'], exitMutexes[count]))
            
            count = count + 1
         
      #----------------------------------------------------------------
      # Wait for all three threads before proceeding 
      #----------------------------------------------------------------
      for mutex in exitMutexes:
         while not mutex.locked (): 
            pass
    

      print "All threads returned from resolveFieldDimensions"
开发者ID:megandamon,项目名称:GmiMetfieldProcessing,代码行数:28,代码来源:GmiGEOS5DasAvg2D.py


示例13: __init__

  def __init__(self, serverIP, port=8000, autoEvents=True): 
    utils.logger.debug("RClient.__init__")
    synchronized.Synchronized.__init__(self)

    dMVC.setRClient(self)

    self.__serverIP   = serverIP
    self.__serverPort = port

    self.__rootModel = None
    self.__sessionID = None
    self.__version = None
    self.__initialDataSemaphore = threading.Semaphore(0)

    self.__answersCommandsList = []

    self.__remoteSuscriptions = {}  

    self.__socket = None
    self.__connect()

    self.__commandQueue = Queue.Queue()
    self.__asyncCommandQueue = Queue.Queue()
    self.__asyncCallback = {}
    self.__fragmentAnswer = {}

    self.__autoEvents = autoEvents
    if self.__autoEvents:
      threadProcessCommand = threading.Thread(target=self.processCommandQueue)
      threadProcessCommand.setDaemon(True)
      threadProcessCommand.start()
    thread.start_new(self.__start, ())
开发者ID:guadalinex-archive,项目名称:genteguada,代码行数:32,代码来源:remoteclient.py


示例14: parent

def parent():
    i = 0
    while 1:
        i = i + 1
        thread.start_new(child, (i,))
        if raw_input() == "q":
            break
开发者ID:Shoklan,项目名称:Documentation,代码行数:7,代码来源:thread1.py


示例15: find_url

def find_url(r, nused):
	while True:
		try:
			for i in r["response"]["posts"]:
			
				id = i["id"]
				id = str(id)
				#print id
				test_url = 'http://api.tumblr.com/v2/blog/'+tumblr+'/posts?id='
				test_url += str(i["id"]) + "&api_key=LavgbZzW1LV2skL5EMhhrEucUPikpP4Ag6KKNBJB77dojfzfaw"
				#print test_url
				testinfo = requests.get(test_url, auth=oauth).json()
				for aa in testinfo["response"]["posts"]:
					if 'photos' not in aa:
						continue
					else:
						for bb in aa["photos"]:
							#print bb["original_size"]["url"]
							filename = str(bb["original_size"]["url"])
							filename = filename.split('_', 1)[-1]
							filename = os.path.join(dest_dir, filename)
							while threading.activeCount() >= 100:
								sleep(2)
							else:
								thread.start_new(download_url, (bb["original_size"]["url"], filename))

		except requests.exceptions.RequestException:
			global problem
			problem = problem + 1
			sleep(5)
			continue
		else:
			break
开发者ID:fanhojo,项目名称:tumblr-picture-downloader,代码行数:33,代码来源:tumblr_picture_downloader.py


示例16: release

    def release(self, path, fh):

        if Debug:
            print "*********************release"
        full_path = self._full_path(path)
        info = self.get_info(path)
        if info == None or info["isdir"]:
            full_path = self._full_path(path)
            raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), full_path)
        if os.stat(info["content_temp_path"]).st_size != 0:
            info["st_atime"] = time.time()
            info["st_size"] = os.stat(info["content_temp_path"]).st_size
            self.filesCollection.update_one({"_id": info["_id"]}, {"$set": {
                "st_size": info["st_size"],
                "st_atime": info["st_atime"]
            }})
            self.set_info(info)
            thread.start_new(self.save, (info,))
            os.close(fh)
        else:
            os.close(fh)
            os.remove(info["content_temp_path"])
            self.fileCacheLock.acquire()
            self.fileCache.pop(info["content_hash"], None)
            self.fileCacheLock.release()
开发者ID:randoms,项目名称:ipfs-data,代码行数:25,代码来源:ipdatafs.py


示例17: __init__

  def __init__(self, input, log):

      for row in input:
          thread.start_new(self.testPort, (row[0], row[1], log))
          self.thread_count = self.thread_count + 1
      while self.thread_count > 0:
          pass
开发者ID:AerohiveAPI,项目名称:Firewall-Port-Test,代码行数:7,代码来源:PortTester.py


示例18: startSkulltag

	def startSkulltag(self, deadArg):
		self.skulltag = subprocess.Popen(['/usr/games/skulltag/skulltag-server', '+sv_markchatlines 1']+self.args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0)
		self.stdinPoll = select.poll()
		self.stdinPoll.register(self.skulltag.stdout, select.POLLIN)
		self.stdoutPoll = select.poll()
		self.stdoutPoll.register(self.skulltag.stdout, select.POLLOUT)
		thread.start_new(self.rwLoop, (None,))
开发者ID:IjonTichy,项目名称:PythonTidbits,代码行数:7,代码来源:sttest.py


示例19: main

def main():
    for i in range(NUM_THREADS):
        thread.start_new(f, (i,))

    time.sleep(LONGSLEEP)

    a = alive.keys()
    a.sort()
    verify(a == range(NUM_THREADS))

    prefork_lives = alive.copy()

    if sys.platform in ['unixware7']:
        cpid = os.fork1()
    else:
        cpid = os.fork()

    if cpid == 0:
        # Child
        time.sleep(LONGSLEEP)
        n = 0
        for key in alive.keys():
            if alive[key] != prefork_lives[key]:
                n = n+1
        os._exit(n)
    else:
        # Parent
        spid, status = os.waitpid(cpid, 0)
        verify(spid == cpid)
        verify(status == 0,
                "cause = %d, exit = %d" % (status&0xff, status>>8) )
        global stop
        # Tell threads to die
        stop = 1
        time.sleep(2*SHORTSLEEP) # Wait for threads to die
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:35,代码来源:test_fork1.py


示例20: makewidget

 def makewidget(self):
     root = Tk()
     root.title('Chat Server...')
     bkInfo = Form(root)
     self.bkInfo = bkInfo
     thread.start_new(self.start,())
     root.mainloop()
开发者ID:peculiarman,项目名称:chatroom_python,代码行数:7,代码来源:ChatServer.py



注:本文中的thread.start_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python thread.start_new_thread函数代码示例发布时间:2022-05-27
下一篇:
Python thread.start函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap