class concurrent.futures.ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())
An Executor subclass that uses a pool of at most max_workers threads to execute calls asynchronously.
initializer is an optional callable that is called at the start of each worker thread; initargs is a tuple of arguments passed to the initializer. Should initializer raise an exception, all currently pending jobs will raise a BrokenThreadPool, as well as any attempt to submit more jobs to the pool.
Changed in version 3.5: If max_workers is None or not given, it will default to the number of processors on the machine, multiplied by 5, assuming that ThreadPoolExecutor is often used to overlap I/O instead of CPU work and the number of workers should be higher than the number of workers for ProcessPoolExecutor.
New in version 3.6: The thread_name_prefix argument was added to allow users to control the threading.Thread names for worker threads created by the pool for easier debugging.
Changed in version 3.7: Added the initializer and initargs arguments.
在Flask应用程序中运行异步任务的一个解决方案是^{} 。在
烧瓶示例
有关在烧瓶中使用
ThreadPoolExecutor
的预先配置的设计模式,请参见Flask-Executor。在Example from Docs
^{pr2}$相关问题 更多 >
编程相关推荐