现象

报错代码

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. OSS网页上传和断点续传(STSToken篇)

    云账号AccessKey拥有所有API访问权限,在客户端不要直接使用,会泄露ak信息,造成安全问题.所以使用STS方式(临时账号权限)给客户端授权. C#版获取STSToken 一.下载阿里SDK(a ...

  2. Echatrs 中PIE饼图中间位置怎么显示总数值?

    title: { text: '总资产', subtext: '2000000.00', x: 'center', y: 'center' }图例:

  3. CRM系统设计方案

    CRM系统设计方案 - 百度文库https://wenku.baidu.com/view/a34eebeb0242a8956bece473.html 服务支持http://www.uf-crm.com ...

  4. mysql之整型数据int

    mysql数据库设计,其中,对于数据性能优化,字段类型考虑很重要,mysql整型bigint.int.mediumint.smallint 和 tinyint的语法介绍,如下:1.bigint 从 - ...

  5. 完美解决safari、微信浏览器下拉回弹效果

    CSS代码: .box{ overflow: auto; -webkit-overflow-scrolling: touch; } HTML代码: <body class="box&q ...

  6. K8S集群 NOT READY的解决办法 1.13 错误信息:cni config uninitialized

    今天给同事 一个k8s 集群 出现not ready了 花了 40min 才搞定 这里记录一下 避免下载 再遇到了 不清楚. 错误现象:untime network not ready: Networ ...

  7. VMWARE中NAT下获取不到IP

    1.编辑-虚拟网络编辑器-dhcp设置 2.虚拟机-可移动设备-网络适配器-设置,注意:这里一定要选nat,当初我就是选了桥接,死活上不去,搞了2个小时.

  8. Linux基础学习笔记6-SHELL编程

    编程基础 程序:指令+数据 程序编程风格: 过程式:以指令为中心,数据服务于指令 对象式:以数据为中心,指令服务于数据 shell程序:提供了编程能力,解释执行 编程基本概念: 顺序执行:循环执行:选 ...

  9. 创建安全客户端Socket

    SocketFactory factory = SSLSocketFactory.getDefault(); Socket socket = factory.create("localhos ...

  10. 莫烦keras学习自修第二天【backend配置】

    keras的backend包括tensorflow和theano,tensorflow只能在macos和linux上运行,theano可以在windows,macos及linux上运行 1. 使用配置 ...