python 线程中出现执行错乱_多处理会导致Python崩溃,并在调用fork()时在另一个线程中出现错误...

我对Python还比较陌生,并尝试为for循环实现一个多处理模块。

我有一个图像url数组存储在img_url中,我需要下载并应用一些Google vision。if __name__ == '__main__':

img_urls = [ALL_MY_Image_URLS]

runAll(img_urls)

print("--- %s seconds ---" % (time.time() - start_time))

这是我的runAll()方法def runAll(img_urls):

num_cores = multiprocessing.cpu_count()

print("Image URLS {}",len(img_urls))

if len(img_urls) > 2:

numberOfImages = 0

else:

numberOfImages = 1

start_timeProcess = time.time()

pool = multiprocessing.Pool()

pool.map(annotate,img_urls)

end_timeProcess = time.time()

print('\n Time to complete ', end_timeProcess-start_timeProcess)

print(full_matching_pages)

def annotate(img_path):

file = requests.get(img_path).content

print("file is",file)

"""Returns web annotations given the path to an image."""

print('Process Working under ',os.getpid())

image = types.Image(content=file)

web_detection = vision_client.web_detection(image=image).web_detection

report(web_detection)

当我运行它并且python崩溃时,我得到这个警告objc[67570]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67570]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

objc[67567]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67567]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

objc[67568]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67568]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

objc[67569]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67569]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

objc[67571]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67571]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

objc[67572]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.

objc[67572]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值