0.1.66版本的pyhanlp,
_________________________-
from multiprocessing import Pool
from pyhanlp import HanLP
print(HanLP.segment(‘hello’))
print(HanLP.parseDependency(‘hello’))
def test_process(tmp: int):
print(str(tmp) + ‘\n’)
print(HanLP.segment(“商品和服务”))
print(HanLP.parseDependency(“商品和服务”))
return str(tmp)
pool_ = Pool(2)
for x in range(1000):
pool_.apply_async(test_process, args=(x, ))
pool_.close()
pool_.join()
print(‘END’)
__________________-
上述代码,主进程已经启动初始化,还是卡在parseDependency,去掉这个则跑得动。
类似问题,多进程跑pyhanlp的NER