(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. 3942: [Usaco2015 Feb]Censoring

    3942: [Usaco2015 Feb]Censoring Time Limit: 10 Sec Memory Limit: 128 MB Submit: 964 Solved: 480 [Subm ...

  2. (十)T检验-第一部分

    介绍T分布.T检验.Z检验与T检验.P值.相依样本以及配对样本的非独立T检验. T分布 在到目前为止举的所有例子中,我们都假设我们知道总体参数 μ 和 σ,但很多时候,我们并不知道,我们通常只有样本, ...

  3. ArrayList实现原理及源码分析之JDK8

    转载 ArrayList源码分析 一.ArrayList介绍 Java 集合框架主要包括两种类型的容器: 一种是集合(Collection),存储一个元素集合. 一种是图(Map),存储键/值对映射. ...

  4. warning:ISO C90 forbids mixed declarations and code

    warning:ISO C90 forbids mixed declarations and code 变量定义之前不论什么一条非变量定义的语句(重视:语句是会带分号的)都会引起这个警告! 将非变量的 ...

  5. 【VSC】我安装了哪些扩展插件

    Nodejs gitk  ——  版本实时比对 Debugger for Chrome ——  让 vscode 映射 chrome 的 debug功能,静态页面都可以用 vscode 来打断点调试. ...

  6. jQuery 基础与运用

    1.  jquery引入以及入口函数 引入方式 <!--方式一:下载到本地,引入路径--> <script src="jquery-3.1.1.min.js"&g ...

  7. 01.创建winserver2012r2+hyper-v+centos7

    1.背景 DELL poweredge T320,装的winserver2012 r2,利用自带的hyper-v安装centos7,后期主要用于spark开发. 1.1 安装winserver2012 ...

  8. rtthread移植到jz2440之BootLoader

    从2016年第一次接触rtthread,感觉很容易上手,记得一个项目是小飞行器上的IPC,趁着空闲,手里有一块jz2440的板子,准备在这块板子上跑起来rtthread,查了很多资料,最后决定自己写一 ...

  9. scala_类的继承

    Scala继承一个基类跟Java很相似, 但我们需要注意以下几点: 重写一个非抽象方法必须使用override修饰符,以及重写父类属性也必须使用override修饰符. 只有主构造函数才可以往基类的构 ...

  10. 经典算法--冒泡排序(Java)

    原理:将相邻元素的较大值赋给右边 思路:① 1.将集合或数组内的第一个元素与第二个元素进行比较,较大值赋给右边: 2.将第二个元素与第三个元素进行比较,较大值赋给右边: ....... (N-1).将 ...