當前位置: 首頁>>代碼示例>>Python>>正文


Python pool.ProcessPoolExecutor方法代碼示例

本文整理匯總了Python中apscheduler.executors.pool.ProcessPoolExecutor方法的典型用法代碼示例。如果您正苦於以下問題:Python pool.ProcessPoolExecutor方法的具體用法?Python pool.ProcessPoolExecutor怎麽用?Python pool.ProcessPoolExecutor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apscheduler.executors.pool的用法示例。


在下文中一共展示了pool.ProcessPoolExecutor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from apscheduler.executors import pool [as 別名]
# 或者: from apscheduler.executors.pool import ProcessPoolExecutor [as 別名]
def __init__(self):
        """Initialize the SQSScheduler, setting up the process pools, scheduler and connecting to the required
        SQS Queues"""
        super().__init__()

        self.pool = ProcessPoolExecutor(1)
        self.scheduler = APScheduler(
            threadpool=self.pool,
            job_defaults={
                'coalesce': True,
                'misfire_grace_time': 30
            }
        )

        session = get_local_aws_session()
        sqs = session.resource('sqs', self.dbconfig.get('queue_region', self.ns))

        self.job_queue = sqs.Queue(self.dbconfig.get('job_queue_url', self.ns))
        self.status_queue = sqs.Queue(self.dbconfig.get('status_queue_url', self.ns)) 
開發者ID:RiotGames,項目名稱:cloud-inquisitor,代碼行數:21,代碼來源:__init__.py

示例2: __init__

# 需要導入模塊: from apscheduler.executors import pool [as 別名]
# 或者: from apscheduler.executors.pool import ProcessPoolExecutor [as 別名]
def __init__(self):
        super().__init__()
        self.collectors = {}
        self.auditors = []
        self.region_workers = []

        self.pool = ProcessPoolExecutor(self.dbconfig.get('worker_threads', self.ns, 20))
        self.scheduler = APScheduler(
            threadpool=self.pool,
            job_defaults={
                'coalesce': True,
                'misfire_grace_time': 30
            }
        )

        self.load_plugins() 
開發者ID:RiotGames,項目名稱:cloud-inquisitor,代碼行數:18,代碼來源:__init__.py

示例3: runScheduler

# 需要導入模塊: from apscheduler.executors import pool [as 別名]
# 或者: from apscheduler.executors.pool import ProcessPoolExecutor [as 別名]
def runScheduler():
    runProxyFetch()

    scheduler_log = LogHandler("scheduler")
    scheduler = BlockingScheduler(logger=scheduler_log)

    scheduler.add_job(runProxyFetch, 'interval', minutes=4, id="proxy_fetch", name="proxy采集")
    scheduler.add_job(runProxyCheck, 'interval', minutes=2, id="proxy_check", name="proxy檢查")

    executors = {
        'default': {'type': 'threadpool', 'max_workers': 20},
        'processpool': ProcessPoolExecutor(max_workers=5)
    }
    job_defaults = {
        'coalesce': False,
        'max_instances': 10
    }

    scheduler.configure(executors=executors, job_defaults=job_defaults)

    scheduler.start() 
開發者ID:jhao104,項目名稱:proxy_pool,代碼行數:23,代碼來源:scheduler.py

示例4: __init__

# 需要導入模塊: from apscheduler.executors import pool [as 別名]
# 或者: from apscheduler.executors.pool import ProcessPoolExecutor [as 別名]
def __init__(self):
        self.run_date = datetime.datetime.now() + datetime.timedelta(seconds=3)
        self.run_date = self.run_date.strftime('%Y-%m-%d %H:%M:%S')
        self.tm = time.strftime('%Y%m%d%H%M%S',time.localtime())
        self.scheduler = BackgroundScheduler()
        self.executors = {'default': ThreadPoolExecutor(10), 'processpool': ProcessPoolExecutor(5)}
        self.job_defaults = {'coalesce': False, 'max_instances': 1}
        self.scheduler.configure(timezone=pytz.timezone('Asia/Shanghai'),job_defaults=self.job_defaults,executors=self.executors) 
開發者ID:wylok,項目名稱:sparrow,代碼行數:10,代碼來源:produce.py

示例5: start_scheduler

# 需要導入模塊: from apscheduler.executors import pool [as 別名]
# 或者: from apscheduler.executors.pool import ProcessPoolExecutor [as 別名]
def start_scheduler(settings):
    assert settings['scheduler.store'] in ('redis', 'sqlalchemy'),\
        'Uknown job store, must by one of redis or sqlalchemy'

    if settings['scheduler.store'] == 'redis':
        jobstores = {
            'default': RedisJobStore(db=settings['scheduler.db'])
        }
    else:
        jobstores = {
            'default': SQLAlchemyJobStore(url=settings['scheduler.url'])
        }
        
    executors = {
        'default': {
            'type': settings['scheduler.executors.type'],
            'max_workers': settings['scheduler.executors.max_workers']
        },
        'processpool': ProcessPoolExecutor(
            max_workers=settings['scheduler.executors.processpool.max_workers']
        )
    }
    job_defaults = {
        'coalesce': False,
        'max_instances': settings['scheduler.job_defaults.max_instances']
    }
    scheduler.configure(
        jobstores=jobstores,
        executors=executors,
        job_defaults=job_defaults,
        timezone=timezone('UTC')
    )
    if settings['scheduler.autostart'] == 'true':
        scheduler.start() 
開發者ID:mazvv,項目名稱:travelcrm,代碼行數:36,代碼來源:__init__.py


注:本文中的apscheduler.executors.pool.ProcessPoolExecutor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。