本文整理汇总了Python中twisted.python.threadpool.ThreadPool.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadPool.__init__方法的具体用法?Python ThreadPool.__init__怎么用?Python ThreadPool.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.threadpool.ThreadPool
的用法示例。
在下文中一共展示了ThreadPool.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.python.threadpool import ThreadPool [as 别名]
# 或者: from twisted.python.threadpool.ThreadPool import __init__ [as 别名]
def __init__(self):
minthreads = config["jobtype_logging_threadpool"]["min_threads"]
maxthreads = config["jobtype_logging_threadpool"]["max_threads"]
self.max_queued_lines = \
config["jobtype_logging_threadpool"]["max_queue_size"]
self.flush_lines = \
config["jobtype_logging_threadpool"]["flush_lines"]
self.stopped = False
if minthreads < 1:
raise ValueError(
"Config value "
"jobtype_logging_threadpool.min_threads must be >= 1")
# Calculate maxthreads if a value was not provided for us
if maxthreads == "auto":
auto_maxthreads = min(int(cpu.total_cpus() * 1.5), 20)
maxthreads = max(auto_maxthreads, minthreads)
if minthreads > maxthreads:
raise ValueError(
"Config value jobtype_logging_threadpool.min_threads cannot "
"be larger than jobtype_logging_threadpool.max_threads")
ThreadPool.__init__(
self,
minthreads=minthreads, maxthreads=maxthreads,
name=self.__class__.__name__)
示例2: __init__
# 需要导入模块: from twisted.python.threadpool import ThreadPool [as 别名]
# 或者: from twisted.python.threadpool.ThreadPool import __init__ [as 别名]
def __init__(self, engine, maxthreads=10, verbose=False):
if engine.dialect.name == 'sqlite':
ThreadPool.__init__(self, minthreads=1, maxthreads=1)
else:
ThreadPool.__init__(self, maxthreads=maxthreads)
self.engine = engine
reactor.callWhenRunning(self.start)
示例3: __init__
# 需要导入模块: from twisted.python.threadpool import ThreadPool [as 别名]
# 或者: from twisted.python.threadpool.ThreadPool import __init__ [as 别名]
def __init__(self, engine, verbose=False):
if engine.dialect.name == "sqlite":
pool_size = 1
ThreadPool.__init__(self, minthreads=1, maxthreads=1)
else:
ThreadPool.__init__(self)
self.engine = engine
reactor.callWhenRunning(self.start)