task.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import threading
  2. from app.api_data.tx_ad_cost.get_cost_older import old_cost_hourly, old_cost_daily
  3. from app.etl.sync_to_ck_task import order_sync_ck
  4. from app.api_data.tx_ad_cost import get_cost_older
  5. from app.etl.data_stat_run import do_cost
  6. from app.api_data.platform_order.order_data_change import insert_order_data_daily,insert_order_data_hourly
  7. from model.DateUtils import DateUtils
  8. du = DateUtils()
  9. def hourly():
  10. t11 = threading.Thread(target=old_cost_hourly)
  11. t12 = threading.Thread(target=insert_order_data_hourly)
  12. t11.start()
  13. t11.join()
  14. t12.start()
  15. t12.join()
  16. def daily():
  17. t11 = threading.Thread(target=old_cost_daily, args=())
  18. t12 = threading.Thread(target=insert_order_data_daily)
  19. t11.start()
  20. t11.join()
  21. t12.start()
  22. t12.join()
  23. def cost_yestoday_repair():
  24. dt = du.get_n_days(-1)
  25. get_cost_older.run(dt, dt)
  26. do_cost(dt, dt)
  27. if __name__ == '__main__':
  28. import logging
  29. from logging import handlers
  30. logging.basicConfig(
  31. handlers=[
  32. logging.handlers.RotatingFileHandler('task.log',
  33. maxBytes=10 * 1024 * 1024,
  34. backupCount=5,
  35. encoding='utf-8')
  36. , logging.StreamHandler() # 供输出使用
  37. ],
  38. level=logging.INFO,
  39. format="%(asctime)s - %(levelname)s %(filename)s %(funcName)s %(lineno)s - %(message)s"
  40. )
  41. # hourly()
  42. # cost_yestoday_repair()
  43. daily()