运行os.fork()报AttributeError: module 'os' has no attribute 'fork'
现象
报错代码
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'的更多相关文章
- python 脚本运行时报错: AttributeError: 'module' object has no attribute ***
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- 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 ...
- AttributeError: module 'datetime' has no attribute 'now'
在用时间转化时,一直报AttributeError: module 'datetime' has no attribute 'now', 我用的 import datetime datetime ...
- 在运行create_list.sh时候报错:AttributeError: 'module' object has no attribute 'LabelMap'
Traceback (most recent call last):File "/opt/xuben-project/caffe/data/VOC0712/../../scripts/cre ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'
一开始在windows下运行没有问题,但是在linux下运行却报如下错误: AttributeError: module 'unittest' has no attribute 'TestRunn ...
- 安装pandas报错(AttributeError: 'module' object has no attribute 'main')
在pycharm中安装pandas出现报错:AttributeError: 'module' object has no attribute 'main', 刚开始以为是pip的版本太旧了,于是乎将其 ...
- 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法
pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...
- 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'
一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...
随机推荐
- c++入门之运算符重载
c++函数重载:可以将一个函数名用于不同功能的函数.从而处理不同的对象.对于运算符,同样也有这样的用途,即对同一个标志符的运算符,可以运用到不同的功能中去. 首先引入:运算符重载,在C语言中甚至都有运 ...
- 第十二届湖南省赛G - Parenthesis (树状数组维护)
Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th questio ...
- vue echarts 动态数据
安装echarts依赖 npm install echarts -S 或者使用国内的淘宝镜像: 安装 npm install -g cnpm --registry=https://registry.n ...
- CGI、FAST-CGI、PHP-CGI、PHP-FPM的关系
转自:https://www.awaimai.com/371.html 关于这一类的文章还有:https://zhuanlan.zhihu.com/p/20694204 在搭建 LAMP/LNMP 服 ...
- 【问题解决方案】Git bash进入多层子目录问题(通配符问题留坑)
cd进入指定路径下:cd 斜杠 斜杠 方法一: 1- 撇丿,不是"那",盘符前面要加上 / (d盘前面也加,不加也行) 2- 路径名不区分大小写 3- 不用空格 4- 如果目录名中 ...
- 墨者学院——密码学加解密实训(Base64转义)
地址:https://www.mozhe.cn/bug/detail/SW5ObnVFa05vSHlmTi9pcWhRSjRqZz09bW96aGUmozhe 在靶场中找到内容 解密 访问直接得key
- WCF使用相关
1.不显示WCF服务主机 在WCF项目属性中的WCF选项卡总关闭下图的选项 2.在其他项目中承载WCF服务 其他加载的操作一致,需要把WCF的endpoint和behavior节点复制到 启动服务的那 ...
- node-cookie-parserDemo
let express = require('express'); let app = new express(); let cookieParser = require('cookie-parser ...
- Errors running builder 'DeploymentBuilder' on project
Errors running builder 'DeploymentBuilder' on project 1.修改java源代码后点击保存,IDE 自动编译并热部署,提示如下错误: Errors o ...
- 关于spring的源码的理解
从最基础的Hello World开始. spring的Hello World就三行代码: public void test() { ApplicationContext context = new C ...