• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现的守护进程(Daemon)用法实例

python实现的守护进程(Daemon)用法实例

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python daemon,daemon进程,daemon 守护进程,daemon tools,daemon tools lite等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python实现的守护进程(Daemon)用法。分享给大家供大家参考。具体如下:

def createDaemon():
  "'Funzione che crea un demone per eseguire un determinato programma…"'
  import os
  # create - fork 1
  try:
    if os.fork() > 0: os._exit(0) # exit father…
  except OSError, error:
    print 'fork #1 failed: %d (%s)' % (error.errno, error.strerror)
    os._exit(1)
  # it separates the son from the father
  os.chdir('/')
  os.setsid()
  os.umask(0)
  # create - fork 2
  try:
    pid = os.fork()
    if pid > 0:
      print 'Daemon PID %d' % pid
      os._exit(0)
  except OSError, error:
    print 'fork #2 failed: %d (%s)' % (error.errno, error.strerror)
    os._exit(1)
  funzioneDemo() # function demo
def funzioneDemo():
  import time
  fd = open('/tmp/demone.log', 'w')
  while True:
    fd.write(time.ctime()+'\n')
    fd.flush()
    time.sleep(2)
  fd.close()
if __name__ == '__main__':
  createDaemon()

</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • python daemon守护进程实现
  • python daemon守护进程实现
  • python实现的守护进程(Daemon)用法实例
  • Python守护进程(daemon)代码实例

相关文章

  • Python常用的内置序列结构(列表、元组、字典)学习笔记
  • Python中is与==判断的区别
  • Python yield 小结和实例
  • Python字符串替换实例分析
  • python3简单实现微信爬虫
  • 浅谈Python 中整型对象的存储问题
  • Python XML RPC服务器端和客户端实例
  • Python ORM框架SQLAlchemy学习笔记之数据查询实例
  • tensorflow查看ckpt各节点名称实例
  • python 链接和操作 memcache方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python文件读写操作与linux shell变量命令交互执行的方法
    • Python基于PycURL实现POST的方法
    • 深入理解python对json的操作总结
    • Python实现批量将word转html并将html内容发布至网站的方法
    • Python实现代码统计工具(终极篇)
    • python 字典(dict)遍历的四种方法性能测试报告
    • python实现按任意键继续执行程序
    • Windows下搭建python开发环境详细步骤
    • Python提取网页中超链接的方法
    • Python中的index()方法使用教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有