本文整理汇总了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')
示例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)
示例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()
示例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))
示例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()
示例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)
示例7: run
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import run [as 别名]
def run(self):
Process.run(self)
示例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')
示例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()
示例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()
示例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")
示例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()
示例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()
示例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()