proxy={"http":"http://127.0.0.1:8087"} ) au_task = taskwork_auspost.AuspostTaskWork(period=3600,group=None) #dbws.QueueWork(dhl) #dbws.QueueWork(auspost) dbws.QueueWork(au_task) if __name__ == '__main__': from DBUtils import PooledDB from vavava import util import MySQLdb,time,os # init log log = util.initlog("./log/"+ os.path.split(__file__)[1]+".log") # init db conn dbpool = PooledDB.PooledDB( MySQLdb,11,22,11,22,False,host='localhost',user='******',passwd='123',db='tracking', charset='utf8' ) conn = dbpool.connection() # init dbworkshop dbws = dbworkshop.DBWorkshop(dbpool=dbpool,minsize=2,log=log) display_str="""test Begin[%s]""" log.info(display_str%(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())))) try: # 开始工作 =============================================================== dbws.StartWork() dhl_test(dbws,conn,log) # 工作完成 ===============================================================
try: seq = 0 wq.Start() for i in range(10): tgw = TestWork(seq=seq) wq.QueueWork(work=tgw) seq += 1 while True: log.info("wq is running ................") time.sleep(1) log.info('main thread(%f):stop', _interval_timer()) wq.Stop() log.info('main thread(%f):stopped', _interval_timer()) except(KeyboardInterrupt): log.info('main thread(%f): User canceled by Ctrl-c', _interval_timer()) finally: log.info('main thread(%f):stop', _interval_timer()) wq.Stop() log.info('main thread(%f):stopped', _interval_timer()) if __name__ == '__main__': from vavava.util import _interval_timer, initlog log = initlog("./log/test_all.log") ################################################### test_workqueue(log) ###################################################