本文整理汇总了Python中multiprocessing.Process.status方法的典型用法代码示例。如果您正苦于以下问题:Python Process.status方法的具体用法?Python Process.status怎么用?Python Process.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Process
的用法示例。
在下文中一共展示了Process.status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import status [as 别名]
def create(self, config):
""" parse config and create relevant classess """
self.logger.debug('Creating new worker')
report = Report()
status = Status()
"""
configuration is stored in JSON format, in database. I chose JSON for
- being able to store as text in database
- easily pass data between server and clients (web, console)
- i like cjson for no particular reason and i want to use it
"""
config = cjson.decode(config)
"""
name string is rewritten as name_timestamp_nodename, to separate the job/worker
easily from others when there are a lot of nodes running around.
Ah yes, forgot to tell. Domo provides a distributed job system, where a job is
a crawling process. Codebase can easily be modified to provide another distributed
somethingation system. Then you can control your remote nodes via a single client.
Thanks to wonderful Pyro framework.
"""
name = config.get('options').get('name')[0]
version = datetime.today().strftime('%Y%m%d%H%M%S')
name = '%s_%s_%s' % (name, version, getnodename())
config.get('options')['name'] = [name]
crawler = Crawler(config, report=report, status=status)
if crawler is not None:
"""
Here spawning a crawler process. Multiprocess library makes controlling spawned
processes as if they were threads, possible.
"""
worker = Process(target=crawler.run, name=name)
# attach shared objects to worker
worker.report = report
worker.status = status
self.workers.update({name: worker})
self.logger.info('Created new worker: %s with status %s' % (name,
worker.status.get()))
# get worker ready for commands
worker.start()
return (True, '%s' % name)
self.logger.error('Could not create new worker')
return (False, 'Could not create new worker')