运行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' 二.问题分 ...
随机推荐
- Python类与对象的理解
注意python的类对象与实例对象的区分 类对象与实例对象是相对的,例如:a=1,那么a就是int的一个实例对象,这里的a相对于int来说,a是实例对象,int是类对象.但是int同时又是type的实 ...
- NFV论文集(三)综述
一 文章名称:Dependability of the NFV Orchestrator: State of the Art and Research Challenges 发表时间:2018 期刊来 ...
- rbac权限+中间件
1.权限组件rbac 1.什么是权限 1 项目与应用 2 什么是权限? 一个包含正则表达式url就是一个权限 who what how ---------->True or Flase 2.版本 ...
- 解决linux用户切换失败 su:execute /usr/bin 没有权限
问题描述: 回宿舍前,在root用户中安装fish,并修改其shell为fish.回宿舍之后,在图形界面用root用户进行登陆,莫名其妙登陆失败.没有任何提示信息,直接回到登陆界面.用非root用户登 ...
- Linux watchdog
使用 watchdog 构建高可用性的 Linux 系统及应用https://www.ibm.com/developerworks/cn/linux/l-cn-watchdog/index.html ...
- php常用方法
在日常开发中,经常我们使用系统方法或者是自己封装的方法进行项目的开发.再此总结一下!!! 一.对于字符串截取 1.使用mbstring扩展 (注意编码的设置) mb_substr($str,2,5, ...
- javascript中的 return false和return true
关于javascript中的 return false和return true,return 是javascript里函数返回值的关键字,一个函数内处理的结果可以使用return 返回,这样在调用函数 ...
- Vue实例:演示input 和 textarea 元素中使用 v-model 实现双向数据绑定
最终效果: 主要代码: <template> <div> <p>input 元素:</p> <input v-model="messag ...
- 当mysql报错1045时的解决方法
2.用记事本打开 添加 打开后,搜索mysqld关键字 找到后,在mysqld下面添加skip-grant-tables,保存退出. 如果保存在了c盘里不能修改那么就采用这样的方法 然后就可以修改c盘 ...
- 隐藏Nginx或Apache以及PHP的版本号的方法
当黑客入侵一台服务器时,首先会”踩点”, 这里的”踩点”,指的是了解服务器中运行的一些服务的详细情况,比如说:版本号,当黑客知道相应服务的版本号后,就可以寻找该服务相应版本的一些漏洞来入侵,攻击,所以 ...