本文整理汇总了Python中multiprocessing.process.Process类的典型用法代码示例。如果您正苦于以下问题:Python Process类的具体用法?Python Process怎么用?Python Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Process类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
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()
开发者ID:guziy,项目名称:PlotWatrouteData,代码行数:34,代码来源:prepare_runoff_for_routing.py
示例2: process
def process(host,port):
from multiprocessing.process import Process
p = Process(target=run, args=(host,port))
p.daemon = True
p.start()
return p
开发者ID:robertbetts,项目名称:Kew,代码行数:7,代码来源:report_control.py
示例3: __init__
def __init__(self, fd, queue):
assert hasattr(queue, 'put')
assert hasattr(queue, 'empty')
assert callable(fd.readline)
Process.__init__(self)
self._fd = fd
self._queue = queue
开发者ID:YunoHost,项目名称:moulinette,代码行数:7,代码来源:stream.py
示例4: service_background_jobs
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')
开发者ID:seanderickson,项目名称:lims,代码行数:32,代码来源:background_processor.py
示例5: lookup
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]
开发者ID:MatiasBjorling,项目名称:bisp,代码行数:28,代码来源:bmanager.py
示例6: process_input_dir
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)
开发者ID:jsouza,项目名称:text_utils,代码行数:28,代码来源:corpora_lemmatizer.py
示例7: __init__
def __init__(self, accessLevel, eightApi):
self.accessLevel = accessLevel
self._eightApi = eightApi
pygame.init()
self.check()
thread = Process(target=self.inputHandler)
thread.start()
开发者ID:SimonKindhauser,项目名称:eight,代码行数:8,代码来源:PscUserInputService.py
示例8: add_server
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)
开发者ID:crawlik,项目名称:ezbake-common-python,代码行数:8,代码来源:ezthrifttest.py
示例9: async_file_reading
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)
开发者ID:YunoHost,项目名称:moulinette,代码行数:8,代码来源:stream.py
示例10: __init__
def __init__(self, pipe, object_class, *args, **kwargs):
Process.__init__(self)
self.object_class = object_class
self.init_args = args
self.init_kwargs = kwargs
self.pipe = pipe
self.command_queue = []
self.message_priorities = {}
开发者ID:jonathanverner,项目名称:qidle,代码行数:8,代码来源:objects.py
示例11: __init__
def __init__(self, sem, port=2022, protocol=ProtocolEnumerator.ECHO, users={}):
Process.__init__(self, name = "SSHServer")
self.port = port
self.users = users
self.privateKeys = {}
self.publicKeys = {}
self.protocol_ = protocol
self.exitCmd = "exit"
self.messages = []
self.sem = sem
开发者ID:sys-git,项目名称:stb-rebooter,代码行数:10,代码来源:SSHServer1.py
示例12: __init__
def __init__(self, **kwargs):
"""
@param init_target: unbound instance method to call at process start
@param wrap_target: unbound instance method to wrap worker function
@param term_target: unbound instance method to call at process finish
"""
self._init_target = kwargs.pop("init_target", lambda self: None).__get__(self, Process)
self._wrap_target = kwargs.pop("wrap_target", lambda self: None).__get__(self, Process)
self._term_target = kwargs.pop("term_target", lambda self: None).__get__(self, Process)
Process.__init__(self, **kwargs)
开发者ID:infinity0,项目名称:tag-routing,代码行数:10,代码来源:contextprocess.py
示例13: __init__
def __init__(self, event_loop = ThreadedEventLoop()):
Process.__init__(self)
self.server_pipe, self.client_pipe = Pipe()
self.server_router = Router(self.server_pipe)
self.client_router = Router(self.client_pipe)
self.srv_command_pipe = self.server_router.create()
self.cli_command_pipe = self.client_router.create(self.srv_command_pipe.id)
self.children = {}
self.client_event_loop = event_loop
self.client_event_loop.register_hook(self.client_router.eventloop_hook)
开发者ID:jonathanverner,项目名称:qidle,代码行数:10,代码来源:factory.py
示例14: test_mcdpweb_server
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')
开发者ID:AndreaCensi,项目名称:mcdp,代码行数:55,代码来源:test_server.py
示例15: __new__
def __new__(self, type_, tId, qDistributor, q, model):
if type_==SolverImplType.THREADED:
thread = threading.Thread(target=SolverWorker, args=[tId, q, qDistributor, model])
thread.setName("LoopingSolver_thread_%(I)s"%{"I":tId})
thread.setDaemon(True)
elif type_==SolverImplType.MULTIPROCESSOR:
thread = Process(target=SolverWorker, args=[tId, q, qDistributor, model])
thread.setName("LoopingSolver_process_%(I)s"%{"I":tId})
thread.setDaemon(True)
else:
raise TypeError("Unknown SolverImplType: '%(T)s'."%{"T":type_})
return thread
开发者ID:sys-git,项目名称:pysudokusolver,代码行数:12,代码来源:AsyncSolverFactory.py
示例16: __init__
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()
开发者ID:SimonKindhauser,项目名称:eight,代码行数:12,代码来源:SteeringService.py
示例17: setUp
def setUp(self):
# Use Thread for debug:
if USE_THREADS:
self.server = Thread(target=ServerLoop, args=(self.container_name,))
else:
self.server = Process(target=ServerLoop, args=(self.container_name,))
self.server.start()
self.count = 0
self.data_arrays_sent = 0
time.sleep(0.1) # give it some time to start
self.rdaemon = Pyro4.Proxy("PYRO:[email protected]/u:"+self.container_name)
self.comp = self.rdaemon.getObject("mycomp")
开发者ID:PierreBizouard,项目名称:odemis,代码行数:13,代码来源:remote_test.py
示例18: import_library_in_another_process
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()
开发者ID:atthaboon,项目名称:RIDE,代码行数:13,代码来源:libraryfetcher.py
示例19: test_litmus_with_authentication
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()
开发者ID:Nonolost,项目名称:wsgidav,代码行数:25,代码来源:test_litmus.py
示例20: main
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()
开发者ID:robertbetts,项目名称:Kew,代码行数:14,代码来源:test_run_report_control.py
注:本文中的multiprocessing.process.Process类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论