Ejemplo n.º 1
0
def get_status(config):
    d = shelve.open(setting.DB_FILE)

    for key in config.keys():
        miner = config[key]

        # pool name is mandatory
        poolname = miner.get('pool', None)
        if (None == poolname):
            logging.error('pool key is not specified')

        apikey = miner.get('apikey', None)
        if (None == apikey):
            logging.error('apikey key is not specified')

        pool = pools.getpool(poolname, apikey)
        if None == pool:
            logging.error('Pool name %s is not valid' % poolname)
            continue

        status = pool.get_status()
        if not status:
            logging.wraning('Pool %s return no data' % poolname)
        status['time'] = datetime.isoformat(datetime.utcnow())

        d[key] = status
        logging.debug(pprint.pformat(status))

    d.close()
Ejemplo n.º 2
0
def _profiling(start, sql=''):
    """
    用于分析 sql 的执行时间
    """
    t = time.time()- start
    if t > 0.1:
        logging.warning('[PROFILING] [DB] %s: %s' % (t, sql))
    else:
        logging.wraning('[PROFILING] [DB] %s: %s' % (t, sql))
Ejemplo n.º 3
0
 def rollback(self):
     global _db_ctx
     logging.warning('rollback transaction...')
     _db_ctx.connection.rollback()
     logging.wraning('rollback ok.')