本文整理汇总了Python中multiprocessing.Process.name方法的典型用法代码示例。如果您正苦于以下问题:Python Process.name方法的具体用法?Python Process.name怎么用?Python Process.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Process
的用法示例。
在下文中一共展示了Process.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attack_deauth
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def attack_deauth(self):
global threadloading
if self.linetarget.text() == '':
QMessageBox.information(self, 'Target Error', 'Please, first select Target for attack')
else:
self.bssid = str(self.linetarget.text())
self.deauth_check = self.xmlcheck.xmlSettings('deauth', 'select',None,False)
self.args = str(self.xmlcheck.xmlSettings('mdk3','arguments', None, False))
self.interface = str(set_monitor_mode(self.get_placa.currentText()).setEnable())
if self.deauth_check == 'packets_scapy':
self.AttackStatus(True)
t = Process(target=self.deauth_attacker, args=(self.bssid,
str(self.input_client.text()),self.interface))
threadloading['deauth'].append(t)
t.daemon = True
t.start()
else:
if path.isfile(popen('which mdk3').read().split("\n")[0]):
self.AttackStatus(True)
t = ProcessThread(('mdk3 %s %s %s'%(self.interface,self.args,self.bssid)).split())
t.name = 'Thread mdk3'
threadloading['mdk3'].append(t)
t.start()
else:
QMessageBox.information(self,'Error mdk3','mkd3 not installed')
set_monitor_mode(self.get_placa.currentText()).setDisable()
示例2: run
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def run(self):
"""
"""
try:
cfg = ConfigParser()
re = cfg.read(CONFIG_FILE)
if CONFIG_FILE not in re:
self.error_parse_config()
except Exception:
self.error_parse_config()
appProcess = list()
for i in cfg.sections():
print "Starting push process for App %s" % cfg.get(i, 'app_name')
p = Process(target=runApp, args=(cfg.getboolean(i, 'app_sandbox'),
cfg.get(i, 'app_cert'),
cfg.get(i, 'app_key'),
cfg.get(i,'driver'),
cfg.get(i, 'queue_host'),
cfg.getint(i,'queue_port'),
cfg.get(i, 'queue_db_name'),
cfg.get(i, 'queue_username'),
cfg.get(i, 'queue_password'),
cfg.get(i, 'app_queue_name'),
cfg.get(i, 'app_name'),
cfg.getboolean(i,'debug'),
cfg.get(i,'feedback_callback'),))
appProcess.append(p)
p.name = cfg.get(i, 'app_name')
p.daemon = True
p.start()
for p in appProcess:
p.join()
示例3: __try_start
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def __try_start(self):
def _wrapper(func, queue):
def _inner(*args, **kwargs):
try:
result = func(*args, **kwargs)
queue.put(result)
finally:
queue.close()
return _inner
if self.is_closed and not self.always_finish:
return
with self.__pending_lock:
with self.__running_lock:
while self.has_pending_processes and not self.is_full:
# Create a new Process
next = self.__pending.pop()
q = Queue()
p = Process(
target=_wrapper(func=next['target'], queue=q),
args=next['args'],
kwargs=next['kwargs'])
if not next['name'] is None:
p.name = next['name']
self.__running.append({
'process': p,
'queue': q,
'callback': next['callback']
})
p.start()
示例4: attack_deauth
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def attack_deauth(self):
global threadloading
if self.linetarget.text() == "":
QMessageBox.information(self, "Target Error", "Please, first select Target for attack")
else:
self.bssid = str(self.linetarget.text())
self.deauth_check = self.xmlcheck.xmlSettings("deauth", "select",None,False)
self.args = str(self.xmlcheck.xmlSettings("mdk3","arguments", None, False))
if self.deauth_check == "packets_scapy":
self.AttackStatus(True)
t = Process(target=self.deauth_attacker, args=(self.bssid,str(self.input_client.text())))
print("[*] deauth Attack On:"+self.bssid)
threadloading['deauth'].append(t)
t.daemon = True
t.start()
else:
if path.isfile(popen('which mdk3').read().split("\n")[0]):
self.AttackStatus(True)
t = ProcessThread(("mdk3 %s %s %s"%(self.interface,self.args,self.bssid)).split())
t.name = "mdk3"
threadloading['mdk3'].append(t)
t.start()
else:
QMessageBox.information(self,'Error mdk3','mkd3 not installed')
set_monitor_mode(self.get_placa.currentText()).setDisable()
示例5: run_tasks
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def run_tasks():
for k,t in __Task_list__.items():
func = t["func"]
intterupt=t["intterupt"]
p=Process(target=__roll__,args=(func,intterupt))
p.name=k
p.daemon=True
p.start()
t["Process"]=p
示例6: upload
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def upload(code, filename = "temp.sl", platform = "telosb"):
with open(filename, "w") as codeFile:
codeFile.write(code)
generateMakefile(filename)
p1 = Process(target = doPopen, args = (["make", platform, "upload"],))
p1.deamonic = True
p1.name = "Upload thread"
p1.start()
示例7: init
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def init(xmpp_server, jid, password, handle_message, msg_queue, child_conn):
# Interprocess queue for dispatching xmpp messages
msg_process = Process(target=message_consumer, args=(xmpp_server, jid, password, handle_message, msg_queue, child_conn))
msg_process.name = 'msg_process'
msg_process.daemon = True
msg_process.start()
return msg_process
示例8: _setup_main_queue
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def _setup_main_queue(self):
self._queue = Queue()
if self._use_processes is True:
t = Process(target=self._process_queue)
else:
t = _Thread(target=self._process_queue)
t.name = "Queue"
t.daemon = True
t.start()
print "Queue started", t
示例9: add_worker
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def add_worker(self):
wname = "PySplash-%s" % self.count
w = Process(target=_worker, args=(wname, self.pool_queue, self.args))
w.name = wname
self.count += 1
worker = {}
worker['state'] = WorkerState.STARTING
worker['last_update'] = time.time()
worker['w'] = w
self.workers[w.name] = worker
self.last_scale = time.time()
w.start()
示例10: test
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def test():
global jobs
req = request.json
if req and 'REPO' in req and 'BRANCH' in req and 'ID' in req and \
any([x for x in config['ARRAYS'] if x['ID'] == req['ID']]):
# Add a check to make sure we aren't already _running_ a job for this
# array
for k, v in jobs.items():
if v['ID'] == req['ID']:
# Update status to make sure
_update_state(k)
if v['STATUS'] == 'RUNNING':
response.status = 412 # Precondition fail
return
# Run the job
# Build the arguments for the script
uri = ""
password = ""
plug = ""
for a in config['ARRAYS']:
if a['ID'] == req['ID']:
uri = a['URI']
password = a['PASSWORD']
plug = a['PLUGIN']
break
# When we add rpm builds we will need client to pass which 'type' too
incoming = ('git', req['REPO'], req['BRANCH'], uri, password)
job_id = _rs(32)
p = Process(target=_run_command, args=(job_id, incoming))
p.name = "|".join(incoming)
p.start()
jobs[job_id] = dict(STATUS='RUNNING',
PROCESS=p,
ID=req['ID'],
PLUGIN=plug)
response.status = 201
return {"JOB_ID": job_id}
else:
response.status = 400
示例11: run
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def run(self):
filename = os.path.join(self.API.path, Settings.get('blockly_location'))
host = Settings.get('blockly_host')
port = int(Settings.get('blockly_port'))
con1, con2 = Pipe()
p1 = Process(target = listen, args = (host, port, con2, True))
p1.daemon = False
p1.name = "Socket listening thread"
try:
p1.start()
self.printLine("Service started successfully.")
if p1.is_alive():
# Damn linux
if os.name == 'posix':
Popen(['xdg-open', filename])
# other OS
else:
webbrowser.open_new_tab(filename)
else:
self.printLine("Failed to open {}:{}, port might be in use.".format(host, port))
lastSync = time.time() + 20
self.API.onExit.append(p1.terminate)
while p1.is_alive() and self.active:
if con1.poll(0.1):
data = con1.recv()
if data != "Sync recieved":
self.handleRecievedCode(data)
lastSync = time.time()
if time.time() - lastSync > 20:
self.printLine("No sync for 20 sec.\nTerminating...")
self.API.onExit.remove(p1.terminate)
p1.terminate()
break
wx.YieldIfNeeded()
if p1.is_alive():
self.printLine("Service terminated successfully.")
self.API.onExit.remove(p1.terminate)
p1.terminate()
except:
self.printLine("Exception occurred, terminating...")
if p1.terminate in self.API.onExit:
self.API.onExit.remove(p1.terminate)
示例12: job_create
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def job_create(repo, branch, array_id):
global jobs
testlib.p("Running test for %s %s %s" % (repo, branch, array_id))
if any([x for x in config["ARRAYS"] if x["ID"] == array_id]):
# Add a check to make sure we aren't already _running_
# a job for this array
for k, v in jobs.items():
if v["ID"] == array_id:
# Update status to make sure
_update_state(k)
if v["STATUS"] == "RUNNING":
return "", 412, "Job already running on array"
# Run the job
# Build the arguments for the script
uri = ""
password = ""
plug = ""
for a in config["ARRAYS"]:
if a["ID"] == array_id:
uri = a["URI"]
password = a["PASSWORD"]
plug = a["PLUGIN"]
break
# When we add rpm builds we will need client to pass
# which 'type' too
incoming = ("git", repo, branch, uri, password)
job_id = _rs(32)
p = Process(target=_run_command, args=(job_id, incoming))
p.name = "|".join(incoming)
p.start()
jobs[job_id] = dict(STATUS="RUNNING", PROCESS=p, ID=array_id, PLUGIN=plug)
return job_id, 201, ""
else:
return "", 400, "Invalid array specified!"
示例13: attack_deauth
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def attack_deauth(self):
global threadloading
if self.linetarget.text() == "":
QMessageBox.information(self, "Target Error", "Please, first select Target for attack")
else:
self.bssid = str(self.linetarget.text())
self.deauth_check = self.xmlcheck.xmlSettings("deauth", "select",None,False)
self.args = str(self.xmlcheck.xmlSettings("mdk3","arguments", None, False))
if self.deauth_check == "packets_scapy":
self.AttackStatus(True)
t = Process(target=self.deauth_attacker, args=(self.bssid,str(self.input_client.text())))
print("[*] deauth Attack On:"+self.bssid)
threadloading['deauth'].append(t)
t.daemon = True
t.start()
else:
self.AttackStatus(True)
t = ProcessThread(("mdk3 mon0 %s %s"%(self.args,self.bssid)).split())
t.name = "mdk3"
threadloading['mdk3'].append(t)
t.start()
示例14: range
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
logger.log("Tor connection failed: {}".format(e), 'error')
time.sleep(5)
# Awaken the spiders!
Spiders = []
Spider_Procs = []
logger.log('Waking the Spiders...', 'info')
my_names = []
# We'll start two processes for every processor.
count = (cpu_count() * 2)
for x in range(count):
spider = Spider()
spider_proc = Process(target=spider.crawl)
spider_proc.name = names.get_first_name()
while spider_proc.name in my_names:
spider_proc.name = names.get_first_name()
my_names.append(spider_proc.name)
Spider_Procs.append(spider_proc)
Spiders.append(spider)
spider_proc.start()
# We make them sleep a second so they don't all go skittering after
# the same url at the same time.
time.sleep(1)
for spider_proc in Spider_Procs:
spider_proc.join()
try:
os.unlink('sleep')
示例15: create_children
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import name [as 别名]
def create_children(self, names=None, new_names=None, classes=None, start=False, use_cgroup=True):
"""If classes, create children from list of classes.
Classes can be a list, or a list of (class, kwargs) tuples
If names, revive named pickles or rerun child if pickle doesn't exist (i.e. save failed).
If neither, revive all pickled children."""
names_and_classes = dict()
if classes is None and names is None:
names = self.child_serialization_filenames.keys()
cgroup = None
if use_cgroup:
cgroup = self.cgroup
if classes is not None:
if type(classes[0]) is not tuple: # if there's just classes (no kwargs) then convert
classes = [(x, {}) for x in classes]
if new_names is None:
new_names = [self.namegen() for _ in range(len(classes))]
for name, a_class in zip(new_names, classes):
names_and_classes[name] = a_class
if names is not None:
for name in names:
exit_code = self.child_processes[name].exitcode
if exit_code is None:
if self.child_processes[name].is_alive():
logger.error("%s: Child %s has not terminated",
self.name, name)
continue
else:
logger.error("%s: Child %s has been created but not started",
self.name, name)
if exit_code < 0:
logger.warn("%s: Child %s exited with code %d and I won't restart it",
self.name, name, exit_code)
continue
elif exit_code == 1:
logger.info("%s: Child %s has a saved state", self.name, name)
names_and_classes[name] = (self.child_classes[name], self.child_kwargs[name])
elif exit_code == 0:
logger.warn("%s: Child %s terminated of its own accord and I won't restart it",
self.name, name)
continue
# Loop over names and classes, creating children
for name, (cl, kwargs) in names_and_classes.iteritems():
child = cl(**kwargs)
child.name = name
self.child_classes[name] = cl
self.child_kwargs[name] = kwargs
# Create conns
child.inbox_conn = self.conns_to_children[child.name] = Queue()
self.conns_from_children[child.name] = child.outbox_conn = Queue()
# Set save file
if name in self.child_processes and self.child_processes[name].exitcode == 1:
# child has been started before
pickle_file = child.save_file = self.child_serialization_filenames[name]
else:
root, ext = os.path.splitext(self.save_file)
child.save_file = self.child_serialization_filenames[name] = root + '_' + name + ext
pickle_file = None
# share communication value
child.flag = self.child_flags[name] = Value('i', 0)
# Create process
p = Process(target=start_communication,
kwargs=dict(agent=child, state_filename=pickle_file, cgroup=cgroup,
password=self.password))
p.name = name
logger.info("%s: Created child %s", self.name, name)
self.child_processes[child.name] = p
self.child_states[name] = 'unstarted'
del child
if start:
p.start()
self.startable_children.update(names_and_classes.keys())
return names_and_classes.keys() # returns list of created child names