def continually_create_merchant_order(minute=1, thread_num="", count=10, interval="0.01"): """ :param count: :param minute:持续时间 :param thread_num: 线程名称 :param interval: 创建运单时间间隔 """ client = KafkaClient(hosts=tmsBase.kafka_client) topic = client.topics[KafkaTopics.RAINBOW.value] duration = minute * 60 start_time = datetime.now() end_time = datetime.now() length = 0 print "Thread-%s begin batch create merchant orders" % thread_num with topic.get_producer() as producer: while (end_time - start_time).seconds < duration: length += InnerInvoker.create_merchant_order( count=count, items=10, thread_no=thread_num, interval=interval, producer=producer )[1] end_time = datetime.now() print "Thread-%s totally created %s merchant orders" % (thread_num, length)
# -*- encoding:utf-8 -*- import sys from time import sleep import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..\\..\\..\\')) from keywords.tms.interface.innerInvoker import InnerInvoker from keywords.tms.base.baseInfo import BaseInfo from keywords.tms.rainbow import RainbowFlow, RainbowUtil from keywords.tms.express.expressFlow import ExpressFlow from keywords.tms.express.expressUtil import ExpressUtil from parameters.tms import tmsBase __author__ = 'bida' if __name__ == '__main__': order_ids = InnerInvoker.create_merchant_order(items=2)[0] sleep(tmsBase.wait_time) if BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name='autoexpress') == 0: obj = BaseInfo.get_subdistributor_id(subdistributor_short_name='autoexpress') delivery_dealer = obj[0] + '-' + obj[1] else: delivery_dealer = BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name='autoexpress') + '-' RainbowFlow.sorting_forward_to_delivery_dealer(order_ids=order_ids, delivery_dealer=delivery_dealer, account='TIANJINSORTING', is_merchant=True) sleep(tmsBase.wait_time) ExpressFlow.express_delivery_api(account='AUTOEXPRESS',