Mac, 多进程+appium,python编译器出现crash

环境:

Appium Desktop V1.7.2 + python 3.6 + Mac 10.12.6

前提:

1. 通过代码自动开启两个Appium进程

2. 通过multiprocessing.Pool()开启子进程 

3. 子进程放在unittest框架中执行,并且appium连接启动手机APP的方法也在子进程中执行

问题:

脚本执行下面代码时,python编译器会出现crash

webdriver.Remote("http://127.0.0.1:" + self.param['p'] + "/wd/hub", self.desired_caps)

查看report后发现问题为:

***multi-thread process forked *** crashed on child side of fork pre-exec

解决方法:

因为在Linux/ Mac, 使用multiprocessing.Pool()时,默认是用fork方式开启子进程,那么就修改开启子进程的方法既可。

  1. multiprocessing.set_start_method('spawn') /
  2. multiprocessing.set_start_method( 'forkserver')

Note:

multiprocessing.set_start_method()只能用在主进程中

参考链接:

https://stackoverflow.com/questions/25260000/scik6it-learns-gridsearchcv-stops-working-when-n-jobs1

https://docs.python.org/dev/library/multiprocessing.html#contexts-and-start-methods


转自: Oops_newbie的博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值