现象

报错代码

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. 七、Json格式的对象都可以通过遍历来获得里面的value值

  2. 书城项目第五阶段---book表的curd

    JavaEE三层架构分析 MVC

  3. 软件工程(FZU2015) 赛季得分榜,第10回合(alpha冲刺)

    SE_FZU目录:1 2 3 4 5 6 7 8 9 10 11 12 13 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分=团队得分+个人贡献分 个人贡献分: 个人 ...

  4. shell脚本--php执行普通shell命令

    这里只演示一些普通的shell命令,一些需要root用户权限执行的命令,请参考:php以root权限执行shell命令 php执行shell命令,可以使用下面几个函数: string system ( ...

  5. 解决selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

    解决方案: 1.查看浏览器当前版本:chrome://version/. 2.到https://sites.google.com/a/chromium.org/chromedriver/downloa ...

  6. PAT 7-14 公路村村通

    https://pintia.cn/problem-sets/1111189748004499456/problems/1111189831248850957 现有村落间道路的统计数据表中,列出了有可 ...

  7. Vmware的虚拟机示例进入BIOS方法

    虚拟机(Vmware)怎么进入BIOS_百度经验 https://jingyan.baidu.com/article/7e440953e566472fc0e2eff7.html Vmware虚拟机进入 ...

  8. oracle导出用户下单表或者多表,导入到别的服务器用户下

      导出   exp 用户名/密码 file=存放dmp的名称的目录 statistics=none tables =(表名,表名,表名) exp creditfw/credit file=d:\te ...

  9. mysql_linux(centos7 mysql 5.7.19)

    centos7  mysql 5.7.19安装 1.解压文件 [root@centos3 ~]# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.g ...

  10. npm的nrm命令使用--设置镜像地址

    npm下载会很慢,因为npm默认从国外下载资源,建议修改npm镜像源地址 1.运行npm i nrm -g全局安装nrm包: 2.使用nrm ls查看当前所有可用的镜像源地址以及当前所使用的镜像源地址 ...