apscheduler_elab.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. from panda_util import PandaUtil
  3. import time
  4. class Config(object):
  5. """
  6. 任务id对应的key
  7. day_push:1
  8. week_push_one:2
  9. week_push_two: 3
  10. """
  11. JOBS = [
  12. {
  13. 'id': 'day_push',
  14. 'func': 'apscheduler_elab:Funcs.day_push',
  15. 'args': '',
  16. 'trigger': 'cron',
  17. 'day_of_week': '*',
  18. 'hour': 9
  19. },
  20. {
  21. 'id': 'week_push_one',
  22. 'func': 'apscheduler_elab:Funcs.week_push_one',
  23. 'args': '',
  24. 'trigger': 'cron',
  25. 'day_of_week': '1',
  26. 'hour': 8,
  27. 'minute': 50
  28. },
  29. {
  30. 'id': 'week_push_two',
  31. 'func': 'apscheduler_elab:Funcs.week_push_two',
  32. 'args': '',
  33. 'trigger': 'cron',
  34. 'day_of_week': '1',
  35. 'hour': 10,
  36. 'minute': 50
  37. }
  38. ]
  39. # 线程池配置
  40. SCHEDULER_EXECUTORS = {
  41. 'default': {'type': 'threadpool', 'max_workers': 20}
  42. }
  43. SCHEDULER_JOB_DEFAULTS = {
  44. 'coalesce': False,
  45. 'max_instances': 3
  46. }
  47. # 调度器开关
  48. SCHEDULER_API_ENABLED = True
  49. pass
  50. class Funcs(object):
  51. @staticmethod
  52. def day_push():
  53. print(time.time())
  54. @staticmethod
  55. def week_push_one():
  56. print(time.time())
  57. @staticmethod
  58. def week_push_two():
  59. print(time.time())
  60. @staticmethod
  61. def minute_push_elab():
  62. pdu = PandaUtil('linshi')
  63. sql = 'select house_id, COUNT(house_id) as number from t_house_image group by house_id limit 5'
  64. file_name = 'pandas_chart_columns2{}.xlsx'.format(time.time())
  65. df_data = pdu.query_data(sql)
  66. print(df_data.size)
  67. pdu.panda_chart([df_data], 1, 'title x', 'title y', file_name)
  68. if __name__ == '__main__':
  69. pass