|
@@ -9,12 +9,18 @@ import pytz
|
|
|
|
|
|
class ApschedulerObject:
|
|
|
def __init__(self, timezone_offset=0.00):
|
|
|
- # 计算时区偏移量(以分钟为单位)
|
|
|
- timezone_offset_minutes = int(timezone_offset * 60)
|
|
|
- timezone = pytz.FixedOffset(timezone_offset_minutes)
|
|
|
- self.scheduler = BackgroundScheduler(timezone=timezone)
|
|
|
- self.scheduler.add_jobstore(DjangoJobStore(), 'default')
|
|
|
- self.scheduler.start()
|
|
|
+ try:
|
|
|
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
+ sock.bind(('127.0.0.1', 12345))
|
|
|
+ except Exception:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ # 计算时区偏移量(以分钟为单位)
|
|
|
+ timezone_offset_minutes = int(timezone_offset * 60)
|
|
|
+ timezone = pytz.FixedOffset(timezone_offset_minutes)
|
|
|
+ self.scheduler = BackgroundScheduler(timezone=timezone)
|
|
|
+ self.scheduler.add_jobstore(DjangoJobStore(), 'default')
|
|
|
+ self.scheduler.start()
|
|
|
|
|
|
@staticmethod
|
|
|
def auto_hello(x): # 任务
|