本文整理汇总了Python中multiprocessing.process.Process.start方法的典型用法代码示例。如果您正苦于以下问题:Python Process.start方法的具体用法?Python Process.start怎么用?Python Process.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.process.Process
的用法示例。
在下文中一共展示了Process.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookup
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def lookup(self, buildingID):
from building.dummy import dummy
'''
@buildingID: int
'''
building = Building.objects.get(bid=buildingID)
print building
if building is None:
return None
if self.binstances.has_key(buildingID) is False:
ins = None
if building.bri == BUILDING_REPRESENTATION_DEBUG:
ins = dummy.DummyBif(buildingID)
elif building.bri == BUILDING_REPRESENTATION_IFC:
raise NotImplementedError, 'Missing implementation of IFC plugin'
elif building.bri == BUILDING_REPRESENTATION_REVIT:
raise NotImplementedError, 'Missing implementation of Revit plugin'
# Fire up the simulator for the building if necessary.
self.comm_queues[buildingID] = Queue()
p = Process(target=_Manager__init_simulator, args=(ins, self.comm_queues[buildingID]))
p.start()
self.binstances[buildingID] = ins
return self.binstances[buildingID]
示例2: test_litmus_with_authentication
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def test_litmus_with_authentication(self):
"""Run litmus test suite on HTTP with authentification.
This test passes
"""
try:
proc = Process(target=run_wsgidav_server, args=(True, False))
proc.daemon = True
proc.start()
time.sleep(1)
try:
self.assertEqual(subprocess.call(["litmus", "http://127.0.0.1:8080/", "tester", "secret"]),
0,
"litmus suite failed: check the log")
except OSError:
print "*" * 70
print "This test requires the litmus test suite."
print "See http://www.webdav.org/neon/litmus/"
print "*" * 70
raise
finally:
proc.terminate()
proc.join()
示例3: main
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def main(gcm="", rcm="", out_folder=""):
pc = None
pf = None
kwargs = {
"start_year": 1970,
"end_year": 1999,
"rcm": rcm, "gcm": gcm,
"out_folder": out_folder
}
in_folder = "data/narccap/{0}-{1}/current".format(gcm, rcm)
if os.path.isdir(in_folder):
pc = Process(target=interpolate_to_amno, args=(in_folder, ), kwargs=kwargs)
pc.start()
else:
print "{0} does not exist, ignoring the period ...".format(in_folder)
kwargs = {
"start_year": 2041,
"end_year": 2070,
"rcm": rcm, "gcm": gcm,
"out_folder": out_folder
}
in_folder = "data/narccap/{0}-{1}/future".format(gcm, rcm)
if os.path.isdir(in_folder):
pf = Process(target=interpolate_to_amno, args=(in_folder, ), kwargs=kwargs)
pf.start()
else:
print "{0} does not exist, ignoring the period ...".format(in_folder)
#do current and future climates in parallel
if pc is not None: pc.join()
if pf is not None: pf.join()
示例4: service_background_jobs
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def service_background_jobs(self):
logger.info('service_background_jobs')
# NOTE: paths must begin with a "/", indicating that the first part of
# the URI is a script name (which each app, i.e "reports" serves as).
# see django.core.handlers.wsgi.__init__
uri = '/' + '/'.join([SCHEMA.REPORTS_API_URI, JOB.resource_name ])
data = {
JOB.STATE: SCHEMA.VOCAB.job.state.PENDING }
kwargs = {}
logger.info('get jobs: %r', uri)
resp = self.api_client.get(
uri, data=data, **kwargs)
job_listing = self.api_client.deserialize(resp)
if API_RESULT_DATA in job_listing:
job_listing = job_listing[API_RESULT_DATA]
for job in job_listing:
logger.info('found job: %r', job)
job_id =job[JOB.ID]
logger.info('Process the job: %r', job_id)
p = Process(target=self.client_processor.service,args=(job_id,) )
# make the parent process wait:
# p.daemon = True
# if set to true, then the parent process won't wait.
logger.info('start')
p.start();
logger.info('started...')
logger.debug('servicing completed')
示例5: process
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def process(host,port):
from multiprocessing.process import Process
p = Process(target=run, args=(host,port))
p.daemon = True
p.start()
return p
示例6: process_input_dir
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def process_input_dir(args, input_path, output_path):
patt = input_path + os.sep + "*" + args.extension
files = glob.glob(patt)
docs_num = len(files)
if docs_num > args.threads:
slice_size = docs_num / args.threads
else:
slice_size = 1
print "Threads:", args.threads
print "Documents number:", docs_num
print "Documents per thread:", slice_size
start = 0
jobs = []
for job_num in range(args.threads):
print "Initializing process", job_num
end = start + slice_size
p = Process(target=lemmatize_files, args=(files[start:end], output_path, args))
print files[start:end]
jobs.append(p)
p.start()
start += slice_size
for p in jobs:
p.join()
if (docs_num % 2) == 1:
lemmatize_files(files, output_path, args)
示例7: add_server
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def add_server(self, app_name, service_name, host, port, processor, use_simple_server=True, wait=1,
use_ssl=False, ca_certs=None, cert=None, key=None):
self.sd_client.register_endpoint(app_name, service_name, host, port)
server_process = Process(target=self.__thrift_server,
args=(processor, host, port, use_simple_server, use_ssl, ca_certs, cert, key))
server_process.start()
time.sleep(wait)
self.server_processes.append(server_process)
示例8: __init__
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def __init__(self, accessLevel, eightApi):
self.accessLevel = accessLevel
self._eightApi = eightApi
pygame.init()
self.check()
thread = Process(target=self.inputHandler)
thread.start()
示例9: async_file_reading
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def async_file_reading(fd, callback):
"""Helper which instantiate and run an AsynchronousFileReader."""
queue = SimpleQueue()
reader = AsynchronousFileReader(fd, queue)
reader.start()
consummer = Process(target=consume_queue, args=(queue, callback))
consummer.start()
return (reader, consummer)
示例10: test_mcdpweb_server
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def test_mcdpweb_server(dirname):
port = random.randint(11000, 15000)
base = 'http://127.0.0.1:%s' % port
p = Process(target=start_server, args=(dirname, port,))
p.start()
print('sleeping')
time.sleep(5)
try:
url_wrong = base + '/not-existing'
urllib2.urlopen(url_wrong).read()
except HTTPError:
pass
else:
raise Exception('Expected 404')
# now run the spider
tmpdir = tempfile.mkdtemp(prefix='wget-output')
cwd = '.'
cmd = ['wget', '-nv', '-P', tmpdir, '-m', base]
# res = system_cmd_result(
# cwd, cmd,
# display_stdout=True,
# display_stderr=True,
# raise_on_error=True)
sub = subprocess.Popen(
cmd,
bufsize=0,
cwd=cwd)
sub.wait()
exc = get_exceptions(port)
if len(exc) == 0:
msg = 'Expected at least a not-found error'
raise Exception(msg)
if not 'not-existing' in exc[0]:
raise Exception('Could not find 404 error')
exc = exc[1:]
if exc:
msg = 'Execution raised errors:\n\n'
msg += str("\n---\n".join(exc))
raise_desc(Exception, msg)
url_exit = base + '/exit'
urllib2.urlopen(url_exit).read()
print('waiting for start_server() process to exit...')
p.join()
print('...clean exit')
示例11: __init__
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def __init__(self):
self.__actualSpeed = Value('f', 0.0)
self._targetSpeed = Value('f', 0.0)
self.__actualDirection = Value('f', 0.0)
self._targetDirection = Value('f', 0.0)
self.__setupMotors()
steering = Process(target=self.steer)
#steering.daemon = True
steering.start()
示例12: import_library_in_another_process
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def import_library_in_another_process(path, args):
q = Queue(maxsize=1)
p = Process(target=library_initializer, args=(q, path, args))
p.start()
while True:
try:
result = q.get(timeout=0.1)
if isinstance(result, Exception):
raise ImportError(result)
return result
except Empty:
if not p.is_alive():
raise ImportError()
示例13: main
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def main():
''' parse the command line - new up the appl and listen on port '''
if os.path.isfile("../kew_pe.conf"):
print ("Loading config file ../kew_pe.conf")
options.parse_config_file("../kew_pe.conf")
options.parse_command_line()
logging.basicConfig(level=logging.DEBUG)
#report_control.process('localhost',8081)
process = Process(target=report_control.run, name="report_control", kwargs={'host':'localhost', 'port':8081})
process.daemon = True
process.start()
示例14: main
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def main():
auth_server = Process(target=run_auth_server)
auth_server.start()
app_server = Process(target=run_app_server)
app_server.start()
print("Access http://localhost:8081/app in your browser")
def sigint_handler(signal, frame):
print("Terminating servers...")
auth_server.terminate()
auth_server.join()
app_server.terminate()
app_server.join()
signal.signal(signal.SIGINT, sigint_handler)
示例15: start_sched
# 需要导入模块: from multiprocessing.process import Process [as 别名]
# 或者: from multiprocessing.process.Process import start [as 别名]
def start_sched():
j_logger.info(u'starting job scheduler ...')
jobs = get_all_jobs()
for job in jobs:
j_logger.info(u'starting job %s ' % job.name)
job.run_status = Value('i', 0) #job的状态值
try:
p = Process(target=_inner_job, name=job.name,args=(job,))
p.start()
job.process_id = p.pid
j_logger.info(u'job %s started !' % job.name)
except Exception as e:
j_logger.error(u'job %s fail to start,due to [%s]!' % (job.name,e))
register_signal_notify()
j_logger.info(u'job scheduler started !')