本文整理汇总了Python中cattle.Config.workers方法的典型用法代码示例。如果您正苦于以下问题:Python Config.workers方法的具体用法?Python Config.workers怎么用?Python Config.workers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cattle.Config
的用法示例。
在下文中一共展示了Config.workers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _args
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import workers [as 别名]
def _args():
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument("--access-key", default=Config.access_key(),
help='Default value from CATTLE_ACCESS_KEY')
parser.add_argument("--secret-key", default=Config.secret_key(),
help='Default value from CATTLE_SECRET_KEY')
parser.add_argument("--url", default=Config.api_url(),
help='Default value from CATTLE_URL')
parser.add_argument("--workers", default=Config.workers(),
help='Default value from CATTLE_WORKERS')
parser.add_argument("--agent-id")
return parser.parse_args()
示例2: _make_session
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import workers [as 别名]
def _make_session():
session = requests.Session()
adapter = requests.adapters.HTTPAdapter(pool_connections=Config.workers(),
pool_maxsize=Config.workers())
session.mount('http://', adapter)
return session
示例3: __init__
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import workers [as 别名]
import logging
from cattle import Config
log = logging.getLogger("concurrency")
__all__ = ["Queue", "Empty", "Full", "Worker", "run", "spawn", "blocking"]
if Config.is_eventlet():
import eventlet
eventlet.monkey_patch()
from eventlet.queue import Queue, Empty, Full
from eventlet import tpool
pool = eventlet.GreenPool(size=Config.workers() * 2)
class Worker:
def __init__(self, target=None, args=None):
self._target = target
self._args = args
def start(self):
pool.spawn_n(self._target, *self._args)
log.info("Using eventlet")
port = Config.eventlet_backdoor()
if port:
from eventlet import backdoor