def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() if __name__ == '__main__': from pytdx.hq import TdxHq_API from pytdx.pool.ippool import AvailableIPPool from pytdx.config.hosts import hq_hosts import random import logging import pprint log.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) # create formatter formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') # add formatter to ch ch.setFormatter(formatter) log.addHandler(ch) ips = [(v[1], v[2]) for v in hq_hosts] # 获取5个随机ip作为ip池 random.shuffle(ips) ips5 = ips[:5]
def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() if __name__ == '__main__': from pytdx.hq import TdxHq_API from pytdx.pool.ippool import AvailableIPPool from pytdx.config.hosts import hq_hosts import random import logging import pprint log.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) # create formatter formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') # add formatter to ch ch.setFormatter(formatter) log.addHandler(ch) ips = [(v[1], v[2]) for v in hq_hosts] # 获取5个随机ip作为ip池 random.shuffle(ips) ips5 = ips[:5] ippool = AvailableIPPool(TdxHq_API, ips5)