(1)p1 = multiprocessing.Process(test1)
p2 = multiprocessing.Process(target=test2)
错误: p1缺少target,应为(target=test1)
Traceback (most recent call last):

  File "D:/untitled/多进程练习.py", line 11, in <module>
    p1 = multiprocessing.Process(test1)
  File "D:\python\lib\multiprocessing\process.py", line 74, in __init__
    assert group is None, 'group argument must be None for now'
AssertionError: group argument must be None for now

(2)  在有进程程序中,没有代码:if __name__ == __main__: 会出现如下错误

RuntimeError: RuntimeError      if __name__ == '__main__': 的作用:防止被被其他文件导入时显示多余的程序主体部分
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.
        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:
            if __name__ == '__main__':
                freeze_support()
                ...
        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.
        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:
            if __name__ == '__main__':
                freeze_support()
                ...
        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
子进程会在运行时拷贝当前主进程中的所有内容,这也就意味着当一个新的子进程被创建的时候,该子进程就会复制当前模块,当然也包括了以下两行:
 
multiprocessing.Process(target=test1).start()
multiprocessing.Process(target=test).start()
很显然,这样的写法可能形成无限递归式地创建新的子进程。所以为了避免以上情况发生,我们在此引入了 if __name__ == __main__: 。

AssertionError的更多相关文章

  1. 开着idea,死机了,关机重启。重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification

    开着idea,死机了,关机重启.重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification. goo ...

  2. [改善Java代码]在switch的default代码块中增加AssertionError错误

    switch的后跟枚举类型,case后列出所有的枚举项,这是一个使用枚举的主流写法,那留着default语句似乎没有任何作用了,程序已经列举出了所有的可能选项,肯定不会执行到default语句,. 错 ...

  3. 【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user

    运行Flask时出现了一个错误, AssertionError: View function mapping is overwriting an existing endpoint function: ...

  4. 解决用try except 捕获assert函数产生的AssertionError异常时,导致断言失败的用例在测试报告中通过的问题

    在使用Python3做自动化测试过程中可能会遇到,assert函数不加try  except,就可以正常在报告里体现用例不通过,加上变成通过. 这是因为在使用try except 时,捕获了asser ...

  5. 运行gulp项目报错:AssertionError: Task function must be specified。

    一.问题描述: gulp项目在本地windows 10机器上跑没有任何问题,但是放在centos 7虚拟机上跑报错:AssertionError: Task function must be spec ...

  6. 出现“java.lang.AssertionError: SAM dictionaries are not the same”报错

    运行一下程序时出现“java.lang.AssertionError: SAM dictionaries are not the same”报错 java -jar picard.jar SortVc ...

  7. rest framework错误笔记——AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set `.queryset` or have a `.get_queryset()` method.

    用到@api_view装饰器时,访问路由查看api数据时,报错: AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly o ...

  8. AssertionError: View function mapping is overwriting an existing endpoint function: admin.main

    刚才给views.py文件添加了一个路由地址: @admin_view.route('/test', methods=["get", "post"]) @log ...

  9. EasyMock set方法报错: java.lang.AssertionError

    有返回值的方法没问题, 直接andReturn就行了. EasyMock.expect(info.getWebTitle()).andReturn(StringUtils.EMPTY).anyTime ...

随机推荐

  1. kubenetes master使用curl 操作API

    前提条件: 已经使用kubeadm 安装集群 查看 kebelet.conf 配置内容 kubectl --kubeconfig /etc/kubernetes/kubelet.conf config ...

  2. 8、Android---探究服务

    8.1.服务是什么 服务(Service)是Android中实现程序后台运行的解决方案 非常适合执行那些不需要和用户交互而且要求长期的任务 服务的运行不依赖于任何用户界面 即使程序被切换到后台 或者用 ...

  3. virtualbox+vagrant学习-2(command cli)-21-vagrant up命令

    Up 格式: vagrant up [options] [name|id] 这个命令根据你的Vagrantfile文件创建和配置客户机. 这是“vagrant”中最重要的一个命令,因为它是创建任何va ...

  4. Java静态代理学习

    代理模式 代理模式的作用是:为其他对象提供一种代理以控制对这个对象的访问. 在某些情况下,一个客户不想或者不能直接引用另一个对象,而代理对象可以在客户端和目标对象之间起到中介的作用. 代理模式一般涉及 ...

  5. 2018-2019赛季最后的随想/$\rm{NOIP2018}$游记·启示录

    他看着眼前的屏幕,静静地发呆. 他不知道迎接他的将会是什么,后天的\(\rm{NOIp}\)终究是个谜. 刚刚给机房里其他人讲完期望的他,打心底觉得自己没有讲好,但效果似乎还可以. "希望别 ...

  6. C语言程序设计I—第十周教学

    第十周教学总结(04/11-10/11) 教学内容 第4章 循环结构-while /do-while语句 4.1用格里高利公式求π的近似值,4.2 统计一个整数的位数 课前准备 在蓝墨云班课发布资源: ...

  7. 使用RT3070使开发板上网

    原文地址:http://www.cnblogs.com/NickQ/p/8973880.html 使开发板上网 USB驱动部分 在arch/arm/mach-s3c2440/mach-smdk2440 ...

  8. spring boot 资料

    http://412887952-qq-com.iteye.com/blog/2344171 http://study.163.com/course/courseMain.htm?courseId=1 ...

  9. 1. [文件]- 文件类型,文件open模式

    1.文件类型:文本文件和二进制文件 硬盘中的文件保存为01010101格式,一般读取文件是把文件从硬盘中读取到内存中. 文本文件需要进行格式转换才能读取出来. 二进制文件一般用于传输 二进制文件:视频 ...

  10. CF535E Tavas and Pashmaks

    今天Fakehu考的T1. 大致意思就是有n个人每个人有两个速度\(v_1,v_2\),比赛有两个路程\(A,B\),最后时间是\(A/v_1+B/v_2\).求每个人是否可能成为冠军中的一个. 显然 ...