def push_thread_function(): from push import Push global _cache push_handle = Push() database = DB() PayLoad = { 'aps':{ 'alert':'%s当前价格为:%s, 已经%s您设定的%s.', 'sound':'default', } } data = json.dumps(PayLoad) while 1: time.sleep(10) platforms = ['okcoin','chbtc','btctrade','fxbtc','mtgox','btc100','btcchina'] for platform in platforms: need_push_big = database.find(platform, _cache[platform], 'b') for one_push in need_push_big: msg = ((data) % (platform, ("%0.2f" % _cache[platform]), "大于", str(one_push[3]))) push_handle.send_message(one_push[0], msg) database.delete(one_push[0], platform, 'high') for platform in platforms: need_push_big = database.find(platform, _cache[platform], 's') for one_push in need_push_big: msg = ((data) % (platform, ("%0.2f" % _cache[platform]), "小于", str(one_push[2]))) push_handle.send_message(one_push[0], msg) database.delete(one_push[0], platform, 'low')