123456789101112131415161718192021222324252627282930313233343536373839 |
- # -*- coding: utf-8 -*-
- import time
- from demeter.core import *
- from gevent import monkey; monkey.patch_socket()
- import gevent
- timeSleep = 15
- def command(file):
- return 'python '+File.path()+'convert.py -f ' + file
- # 文档转换
- def convert():
- r = Demeter.redis()
- c = Demeter.config['redis']
- i = 0
- while 1:
- file = r.lpop(c['name'])
- if file:
- g = command(file)
- Shell.popen(g, True, True)
- i = i+1
- if i >= 10:
- gevent.sleep(timeSleep)
- i = 0
- # 清理一天前的sign
- def signature():
- while 1:
- service = Demeter.service('convert')
- service.crearSignature()
- gevent.sleep(3600)
- def handle():
- gevent.joinall([
- gevent.spawn(convert),
- gevent.spawn(signature),
- ])
- handle()
|