添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
with concurrent.futures.ProcessPoolExecutor() as executor: roots = glob('/root/images/*.jpg') executor.map(verify.get_text, roots)

像上面的代码在运行时,就会报这个 can’t pickle Transaction objects 错误。

map不能直接操作对象

from glob import glob
import os
import concurrent.futures
from multiprocessing import Pool
import lmdb
import time
A = None
class VerifyLabel:
	def __init__(self):
		self.file_name = ''
	def check_txt(self, file_name):
		print(f'file_name:{self.file_name}')
def check_txt( file_name):
		global A
		print(f'file_name:{A.file_name}')
if __name__ == "__main__":
    verify = VerifyLabel()
	A = verify
    with concurrent.futures.ProcessPoolExecutor() as executor:
        roots = glob('/root/images/*.jpg')
        executor.map(verify.get_text, roots)

这样就不会错了。