Python后台执行不启用缓存
2024-08-22 20:11:10
1、运行时加-u参数,如 # python3 -u test.py >> test.log &
用man查看python的-u参数,说明如下:
Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file-object iterators (“for line in sys.stdin”) which is not influenced by this option. To work around this, you will want to use “sys.stdin.readline()” inside a “while 1:” loop.
强制stdin,stdout和stderr完全不缓冲。
2、在不要缓冲的每一次print后面添加sys.stdout.flush()函数
3、脚本头部添加-u,如#!/usr/local/bin/python -u,道理同方法1
4、添加环境变量 PYTHONUNBUFFERED=1
最新文章
- CMD安装/删除服务
- user initialization list vs constructor assignment
- 如何使用Chrome Timeline 工具(译)
- CSS隐藏元素的几种方法
- Find them, Catch them
- UVa 10250 The Other Two Trees
- 从 Page not found: / 提示说起,我是怎么发现webstrom与myeclipse冲突问题及解决的
- 在VSTO界面中,调用xll中的函数
- Android Studio 调试过程中快捷查看断点处变量值(Ctrl+Shift+I无效)?
- Python中关于XML-RPC原理
- mysql_view
- .1-Vue源码起步
- 用python爬整本小说写入txt文件
- python matplotlib 播放图片变化过程
- Python 的 urllib.parse 库解析 URL
- html5-progress和meter用法
- [JSP] Action Tags
- Apache按天截断日志工具,无法生成访问日志
- N! (大数,优化)
- 解决redis-cli command not found问题
热门文章
- flask 设置访问地址 和 访问端口
- How to receive JSON as an MVC 5 action method parameter
- Guided Hacking DLL Injector 3.3
- JVM 自定义类加载器
- 脸型分类-Face shape classification using Inception v3
- JS构造函数中有return
- gitlab 构建常见错误
- c代码审查软件
- python清理docker-harbor的多余镜像
- idea-debug启动会卡住不动,BeanPostProcessors (for example: not eligible for auto-proxying),报错解决