gevent #287

Merged
Atheros1 merged 19 commits from master into master 2013-07-05 22:59:12 +02:00
Showing only changes of commit 6facca4cb3 - Show all commits

38
src/class_bgWorker.py Normal file
View File

@ -0,0 +1,38 @@
#! /usr/bin/python
# -*- coding: utf-8 -*-
# cody by linker.lin@me.com
__author__ = 'linkerlin'
import threading
import Queue
import time
class BGWorker(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.q = Queue.Queue()
def post(self,job):
self.q.put(job)
def run(self):
while 1:
job=None
try:
job = self.q.get(block=True)
if job:
job()
except Exception as ex:
print "Error,job exception:",ex.message,type(ex)
time.sleep(0.05)
else:
#print "job: ", job, " done"
pass
finally:
time.sleep(0.05)
bgworker = BGWorker()
bgworker.setDaemon(True)
bgworker.start()