Use python's futures.ThreadPoolExecutor
is, if you call submit to submit the task
ThreadPoolExecutor will be executed
self._work_queue.put(w)
in
self._work_queue = queue.SimpleQueue()
SimpleQueue does not limit the size of the queue. If too many tasks are submitted and the processing is not timely, it will occupy too much memory
Can be replaced to the implementation of queue.Queue(maxsize=maxsize)
class ThreadPoolExecutorWithQueueSizeLimit(futures.ThreadPoolExecutor):
def __init__(self, maxsize=50, *args, **kwargs):
super(ThreadPoolExecutorWithQueueSizeLimit, self).__init__(*args, **kwargs)
self._work_queue = queue.Queue(maxsize=maxsize)
links:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。