当前位置: 首页>>代码示例>>Python>>正文


Python Process.run方法代码示例

本文整理汇总了Python中multiprocessing.Process.run方法的典型用法代码示例。如果您正苦于以下问题:Python Process.run方法的具体用法?Python Process.run怎么用?Python Process.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.Process的用法示例。


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

示例1: PySvc

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
class PySvc(win32serviceutil.ServiceFramework):
    _svc_name_ = "CloudStack_WDS_Agent"
    _svc_display_name_ = "CloudStack WDS Agent"
    _svc_description_ = "WDS Agent for CloudStack"

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)

    # core logic of the service
    def SvcDoRun(self):
        self.process = Process(target=self.main)
        self.process.start()
        self.process.run()

    # called when we're being shut down
    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        self.process.terminate()
        self.ReportServiceStatus(win32service.SERVICE_STOPPED)

    def main(self):
        handler = RotatingFileHandler(app.instance_path + '\\agent.log', maxBytes=10000, backupCount=1)
        handler.setLevel(logging.INFO)
        app.logger.addHandler(handler)
        load_configuration()
        app.run(threaded=True, port=8250, host='0.0.0.0', ssl_context='adhoc')
开发者ID:rags22489664,项目名称:FlaskProxy,代码行数:28,代码来源:WDSFlask.py

示例2: main

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
def main(setpoint,ip=None):
    aa=cliente_lib()
    if ip!=None:
       aa.ip=ip
    cliente=aa.cliente_inicio()
    c=gamepad()
    try:
       pipe,msg=c.gamepad_init()
    except:
       aa.Cliente_apaga(cliente)
       exit(1)
    q = Queue() #orden de palanca
    q1 =Queue() #velocidad para el robot
    #anadir info para que tenga datos de trabajo al iniciar
    q.put(1)
    q1.put(-1)
    #comienzo de procesos
    p = Process(target=palanca, args=(c,pipe,msg,q,))
    p1 = Process(target=fuzzy_velocidad, args=(q1,setpoint,aa,cliente,))
    p.start()
    p1.start()
    while 1:
        p1.run()
        #sleep(0.1)
        p.run()
        a=robot_ordenes(q,q1,aa,cliente)
        if a=="r2":
            break
    p1.terminate()
    p.terminate()
    aa.cliente_apaga(cliente)
开发者ID:badanni,项目名称:cthulhu,代码行数:33,代码来源:multiprocesosV0.py

示例3: buildThread

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
class buildThread(object):

    def __init__(self, target, clicrud, **kwargs):
        self._kwargs = kwargs
        self._kwargs['setup'] = clicrud
        self._q = Queue()
        self._finq = Queue()
        self._ranonceq = Queue()
        self._target = target
        self._clicrud = clicrud
        self._ranonce = False

    def __str__(self):
        return str(self._kwargs)

    def output(self):
        return self._q.get()

    def prettyOutput(self):
        _output = self._q.get()
        _return = ""
        for k, v in _output.iteritems():
            _return += "\n\nCOMMAND: " + k + "--------------------\r\n\n"
            _return += v + "\n"
        return _return

    @property
    def finq(self):
        return self._finq.get(timeout=600)

    def start(self):
        self._t = Process(target=self._target,
                          args=(self._q,
                                self._finq,
                                self._ranonceq),
                          kwargs=self._kwargs,)

        self._t.start()

    def stop(self):
        self._t.terminate()

    def join(self):
        self._t.join()

    def run(self):
        self._t.run()

    @property
    def ranonce(self):
        return self._ranonceq.get(timeout=1800)

    def getPID(self):
        return self._t.pid

    def test(self):
        return self._t._bootstrap()
开发者ID:manasdk,项目名称:clicrud,代码行数:59,代码来源:multiprocess.py

示例4: Handler

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
class Handler(object):
    """Handle a single message.
    """
    def __init__(self, envelope, q, qlock, timeout=Rx.timeout):
        self.q = q
        self.qlock = qlock
        self.envelope = envelope
        self.timeout = timeout
        self.p = None

    def start(self):
        if self.p is None:
            name = '%s/%s' % (__package__, self.envelope.uuid)
            self.p = Process(target=self.handle,
                             args=(self.envelope.message,),
                             name=name)
            self.p.run()
        return self.p

    def handle(self):
        m = self.envelope.message
        assert isinstance(m, DrC)
        if isinstance(m, run.Run):
            self.run(m.task)
        raise ValueError('Unknown message type: %s (%s)',
                         self.envelope.type,
                         m.__class__.__name__)

    def post(self, message):
        envelope = Envelope(dict(channel=self.envelope.channel,
                                 refs=[self.envelope.uuid],
                                 data=message))
        with self.qlock:
            self.q.put(envelope)

    def run(self, task):
        assert isinstance(task, Task)
        self.post(run.Status(uuid=task.uuid, status=Status.started))
        try:
            with flock(self.subsidiary_lock(task.lock), seconds=Rx.timeout):
                return task.run()
        except Timeout as e:
            self.post(run.Status(uuid=task.uuid,
                                 status=Status.failed,
                                 message=str(e)))
        self.post(run.Status(uuid=task.uuid, status=Status.success))
开发者ID:drcloud,项目名称:junkyard,代码行数:48,代码来源:__inotify__.py

示例5: run

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
    def run(self):
        while True:
            # Main code goes here ...
            # Note that logger level needs to be set to logging.DEBUG before
            # this shows up in the logs
            logger.debug("Starting main loop")

            if __name__ == '__main__':
                logger.debug('Starting Main')
                info('main line')
                p = Process(target=pcontrol.pControl, args=(org, place, brokerIP, clientId))
                p.start()
#                o = Process(target=airsensor.airSensor, args=(org, place, brokerIP, clientId, cfgfile))
#                o.start()
                while True:
                    if not p.is_alive():
                       logger.warning('pControl is DEAD - Restarting-it')
                       p.terminate()
                       p.run()
                       time.sleep(0.1)
                       logger.warning("New PID: " + str(p.pid))
                p.join()
开发者ID:SensSolutions,项目名称:sens_platform,代码行数:24,代码来源:psens2.py

示例6: test_timer

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
def test_timer():

    func = printfirst
    params = 'Jane'

    publisher = Publisher()
    fname = 'update.pid'
    args = [func, params, '11:11:30', '00:03:00', fname, publisher]

    # None started so should be True
    assert(timechecker._nonerunning(fname))

    p1 = Process(target=timechecker.timer, args=args)
    p1.daemon = True
    p1.start()
    time.sleep(0.1)

    # One already started so should be False
    assert(not timechecker._nonerunning(fname))

    p1.terminate()
    os.remove(fname)

    p2 = Process(target=timechecker.timer, args=args)
    p2.daemon = True
    p2.start()
    time.sleep(0.1)

    pfail = Process(target=timechecker.timer, args=args)
    pfail.daemon = True

    # One already started so should raise OSError
    with pytest.raises(OSError):
        pfail.run()
        pfail.terminate()

    p2.terminate()
    os.remove(fname)
开发者ID:Intelimetrica,项目名称:cacheful,代码行数:40,代码来源:test_timechecker.py

示例7: run

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
 def run(self):
     Process.run(self)
开发者ID:domoritz,项目名称:SoSAT,代码行数:4,代码来源:benchmark.py

示例8: Process

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
# Start process
#
    logger.warning("Cache prefix: %s", cachefile)
    try:
         logger.debug('Starting pControl')
         p = Process(target=pcontrol.pControl, args=(org, place, brokerIP, clientId, cachefile))
         p.start()
         logger.warning('Starting pControl, PID: %s', str(p.pid()))

   #        o = Process(target=airsensor.airSensor, args=(org, place, brokerIP, clientId, cfgfile))
   #        o.start()
         while True:
             if not p.is_alive():
                 logger.warning('pControl is DEAD - Restarting-it')
                 p.terminate()
                 p.run()
                 time.sleep(0.1)
                 logger.warning("New PID: %s", str(p.pid))
             '''
             if not o.is_alive():
                 logger.warning('airSensor is DEAD - Restarting-it')
                 o.terminate()
                 o.run()
                 time.sleep(0.1)
                 logger.warning("New PID: " + str(o.pid))
             '''


    except KeyboardInterrupt:
# KeyboardInterrupt
         logger.warning('Shutingdown Monitoring system')
开发者ID:SensSolutions,项目名称:sens_platform,代码行数:33,代码来源:psens3.py

示例9: info

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]

if __name__ == '__main__':
    logger.debug('Starting Main')
    info('main line')
    p = Process(target=pcontrol.pControl, args=(org,place,brokerIP,clientId))
    p.start()

    o = Process(target=airsensor.airSensor, args=(org,place,brokerIP,clientId,cfgfile))
    o.start()

    while True:
        if not p.is_alive():
           logger.warning('pControl is DEAD - Restarting-it')
           p.terminate()
           p.run()
           time.sleep(0.1)
           logger.warning( "New PID: " + str(p.pid))

        if not o.is_alive():
           logger.warning('airSensor is DEAD - Restarting-it')
           o.terminate()
           o.run()
           time.sleep(0.1)
           logger.warning( "New PID: " + str(o.pid))



    p.join()
    o.join()
开发者ID:kcraam,项目名称:rasp-tempsensor,代码行数:31,代码来源:sensor.py

示例10: run

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
 def run(self):
     Process.run(self)
     for i in range(self.num_circuits):
         self.s.connect(self.factory)
     reactor.run()
开发者ID:jelices,项目名称:MeasureTor,代码行数:7,代码来源:client.py

示例11: Install

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
def Install(button):
	boton2.set_sensitive(False)
	if casilla9.get_active():
		os.system(dump_registry_to_a_file)
		etiqueta_ventana_no_passwd.set_text(log_created_no_passwd)
		etiqueta_ventana_wrong_passwd.set_text(log_created_wrong_passwd)
	Passwd = PasswdEntry.get_text().rstrip()
	print Passwd
	if Passwd == "":
		ventatana_no_passwd.connect("delete_event", Esconder)
		ventatana_no_passwd.set_position(Gtk.WindowPosition.CENTER)
		ventatana_no_passwd.show_all()
		boton_none.connect("clicked", EsconderNone)
		boton2.set_sensitive(True)
	else:
		os.environ["Passwd"] = Passwd
		try:
			Bash_Passwd = subprocess.check_output(""" autosudo () {  echo "$Passwd" | sudo -S "[email protected]" ; } ; autosudo echo "Hola" > /dev/null 2>&1 """, shell=True).rstrip("""\n""")
		except:
			ventatana_wrong_passwd.connect("delete_event", EsconderWrong)
			ventatana_wrong_passwd.set_position(Gtk.WindowPosition.CENTER)
			boton_wrong.connect("clicked", EsconderWrong)
			ventatana_wrong_passwd.show_all()
			boton2.set_sensitive(True)
		else:
			
			os.system(""" bash -c '
	
				autosudo () {  echo "$Password" | sudo -S "[email protected]" ; }
				
				mkdir -p "$ProgressFileLocation"
				
				autosudo chmod 777 "$ProgressFileLocation"
				
				echo "0.00" > "$ProgressFileLocation/Progress.txt"	
				
				' """)
			
			def Ok():
	
				try:
		
					ProgressFile = os.environ["ProgressFileLocation"] + "/Progress.txt"
					file = open(ProgressFile)
					txt = file.read()
		
					number = float(txt)
						
					barra_de_progreso.set_fraction(number)
		
				except ValueError:
		
					pass
	
				if number != 1.00:
					threading.Timer(0.01, Ok).start()
		
				
			def P1():
				
				os.system(""" for i in $(seq 0.01 0.01 1.00); do sleep 0.01;echo "$i" > "$ProgressFileLocation/Progress.txt" ; done """)				
			
			p1 = Process(target=Ok)
			p2 = Process(target=P1)

			p1.run()
			p2.start()
						
			boton2.set_sensitive(False)
			print ("Fin")
开发者ID:guekho64,项目名称:Minecraft-Installer-for-Ubuntu-GUI,代码行数:72,代码来源:Main.py

示例12: GameOfLife

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
if __name__ == "__main__":
	

	
	GOL = GameOfLife(50, 30,False, None)
	##ToffMunstur til ad byrja med
	GOL.openPattern('Default.rle')
	GUI = GameOfLifeGUI(GOL)	
	p, g = None, None
	
	#Thad er ekki haegt ad hafa thetta i thradum/processum, thvi badir thurfa ad keyra gtk.main_iteration til ad nota vidmotid/teikna
	g = Process(target = gtk.main_iteration, args = (False,))
	w = GUI.Waiter()
	s = GUI.Simulator()
	u = GUI.Updater()
	gtk.gdk.threads_init()
	gtk.gdk.threads_enter()
	while(GUI.Running):
		while gtk.events_pending(): 
			g.run()
		if(GUI.Play):
			if not w.is_alive():
				w.run(GUI)
			if not s.is_alive():
				s.run(GUI)
			if not u.is_alive():
				u.run(GUI)
		
	gtk.gdk.threads_leave()
开发者ID:Tritlo,项目名称:GameOfLife,代码行数:31,代码来源:GameOfLifeGUI.py

示例13: Lock

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
        self.lock = Lock()
        
        

    def Enqueue(self,msg):
        with self.lock:
            self.val.put(msg)
    def Dequeue(self):
        with self.lock:
            return self.val.get()
    def Empty(self):
        return self.val.empty()
    def Count(self):
        return self.val.qsize()
        
        

if __name__ == '__main__':
    queue = Q()
    #startIS()
   
    p1 = Process(target = startIRC, args = (queue,))
    p2 = Process(target = startIS, args = (queue,))

    p2.run()
    p1.run()
    
    reactor.run()

    
开发者ID:Crysco,项目名称:Invasion,代码行数:30,代码来源:ircLogBot2.py

示例14: Imap

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
                ap.start()
                suppliers.append(ap)

            if conf.getboolean('suppliers','mail'):
                print "[+] Starting mail supplier!"
                imap = Imap()
                mp = Process(target=imap.run, args=(mail_queue,))
                mp.daemon = True
                mp.start()
                suppliers.append(mp)

            if conf.getboolean('suppliers','dir'):
                print "[+] Starting Directory monitor!"
                monitor = Process(Monitor, args=(conf.get('settings','dirmonitor'),dist_queue,))
                monitor.daemon = True
                monitor.run()
                suppliers.append(monitor)

            # Starting workers
            #Portable Executables
            for i in range(4):
                p = PEWorker(pe_queue, dist_queue)
                p.daemon = True
                p.start()
                workers.append(p)

            #Office
            for i in range(nr_processes):
                p = OfficeWorker(doc_queue, dist_queue)
                p.daemon = True
                p.start()
开发者ID:nheijmans,项目名称:MalZoo,代码行数:33,代码来源:malzoo.py


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