现象

报错代码

def handle(s, c, db):
pid = os.fork()
if pid == 0:
s.close()
do_child(c, db)
sys.exit()
else:
c.close()

在电子词典项目中尝试使用多进程来完成并发的 socket 处理的时候报错

分析

windows 平台下无法使用  os.fork ,

IDE 虽然不会报错.但是程序执行起来之后确实无法使用

解决方法

并发的手段处理有很多方法,比如这里用了协程一样完成了相关的操作

虽然本来想使用  multiprocessing 来创建多进程,但是因为需要把 多进程写在 main 下有点冲突于是选择了更简单的协程

        gevent.spawn(do_child, c, db)

运行os.fork()报AttributeError: module 'os' has no attribute 'fork'的更多相关文章

  1. python 脚本运行时报错: AttributeError: 'module' object has no attribute ***

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  2. Python 3.6安装yaml时报"AttributeError: module 'pip' has no attribute 'main'"和“Non-zero exit code”错误

    1.Python 3.6安装yaml时一开始报AttributeError: module 'pip' has no attribute错误,根据网上提供的解决方法修改Pycharm安装目录D:\Pr ...

  3. AttributeError: module 'datetime' has no attribute 'now'

    在用时间转化时,一直报AttributeError: module 'datetime' has no attribute 'now', 我用的 import datetime   datetime ...

  4. 在运行create_list.sh时候报错:AttributeError: 'module' object has no attribute 'LabelMap'

    Traceback (most recent call last):File "/opt/xuben-project/caffe/data/VOC0712/../../scripts/cre ...

  5. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  6. unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'

    一开始在windows下运行没有问题,但是在linux下运行却报如下错误: ​ AttributeError: module 'unittest' has no attribute 'TestRunn ...

  7. 安装pandas报错(AttributeError: 'module' object has no attribute 'main')

    在pycharm中安装pandas出现报错:AttributeError: 'module' object has no attribute 'main', 刚开始以为是pip的版本太旧了,于是乎将其 ...

  8. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

    pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...

  9. 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'

    一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...

随机推荐

  1. linus 下redis守护进程启动

    修改配置文件 sudo vim /usr/src/redis/redis.conf // 具体的安装目录不一样,以安装的时候为准 # 将daemonize 改为yes daemonize yes 重新 ...

  2. 牛客练习赛 A题 筱玛的快乐

    链接:https://ac.nowcoder.com/acm/contest/342/A来源:牛客网 筱玛的快乐 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 524288K,其他语 ...

  3. C#跨进程读取listview控件中的数据

    http://www.cnblogs.com/Charltsing/p/slv32.html 欢迎交流:QQ564955427 读取标准的32位listview控件中的数据,网上已经有很多代码了.今天 ...

  4. 福州大学软件工程1816 | W班 第10次作业[软件工程实践总结]

    作业链接 个人作业--软件工程实践总结 评分细则 本次由五个问题(每个十分)+创意照片(五分)+附加题(十分)组成 评分统计图 千帆竞发图 汇总成绩排名链接 汇总链接

  5. Is-a

    在知识表示.面向对象程序设计与面向对象设计的领域里, is-a(英语:subsumption,包含架构)指的是类的父子继承关系, 例如类D是另一个类B的子类(类B是类D的父类). 换句话说,通常&qu ...

  6. PHP中友好的处理方式

    在使用PHP进行开发的时候,由于PHP是弱类型语言的特性,所以,偶尔会遇到一些意想不到的错误.规范我们的编程就变得尤为重要了.下面总结一下,我日常开发中的一些经验,可能有些地方不妥,还请多多斧正,指教 ...

  7. PreparedStatement 与 Statement 的区别

    1. PreparedStatement 接口继承 Statement, PreparedStatement 实例包含已编译的 SQL 语句,所以其执行速度要快于 Statement 对象. 2.作为 ...

  8. [转帖]SAP一句话入门:Production Planning

    SAP一句话入门:Production Planning http://blog.vsharing.com/MilesForce/A617692.html SAP是庞大的,模块是多多的,功能是强大的, ...

  9. Linux(CentOS7)命令学习摘要

    1. 修改机器名 hostnamectl set-hostname newname 2. hosts主机存放位置 /etc/hosts 3. 安装tigervncserver, 然后使用vncserv ...

  10. 在eclipse中spring的xml配置文件标签中class路径全限定名自动提示设置

    这个自动提示其实很简单,没有网上说的那些要在help下的Install中输入网址来下载更新一堆东西那么复杂. 只需要打开Help — — >Eclipse Marketplace... 然后在该 ...