push.closeAll() for connection in connections: connection.close() def main(): try: init_thread() except Exception, e: closeAll() print "failed to initiate threads" print e sys.exit(0) if __name__ == "__main__": push = GCMLogic() THREADS = 5 connections = [] for thread in range(THREADS): try: connections.append(push.getConnection()) except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) closeAll() sys.exit(1) main()
#!/usr/bin/python from gcm_push_data import PushData from gcm_logic import GCMLogic from gcm_setup import AllSetup import push_gcm if __name__ == "__main__": push = PushData() setup = AllSetup() push.setData(data=None, collapse_key='push', delay_while_idle=False, time_to_live=86400) push.writeData(setup.push_file) logic = GCMLogic(1) devices = logic.getDevices() logic.sendPushToDevices(devices)