代码拉取完成,页面将自动刷新
同步操作将从 banzhuanxiaodoubi/wenjian 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import logging
import queue
from time import sleep
from flask import json, current_app, app
from messenger.apps.vmachine.handlers import CreateVmachine
from messenger.utils.response_util import RET
class Task(object):
def __init__(self, priority_queue_job_param):
self._priority = priority_queue_job_param.priority
self._job_type = priority_queue_job_param.job_type
self._time = priority_queue_job_param.sub_time
self.body = priority_queue_job_param.body
self.auth = priority_queue_job_param.auth
def __str__(self):
return "Task(priority={}, name={}, time={}).".format(self._priority, self._job_type, self._time)
def __lt__(self, other):
if self._priority != other._priority:
return self._priority < other._priority
else:
return self._time < other._time
class JobQueue():
instance = None
init_flat = False
def __new__(cls, *args, **kwargs):
if cls.instance is None:
cls.instance = super().__new__(cls)
return cls.instance
def __init__(self):
if self.init_flat == True:
return
self.queue = queue.PriorityQueue()
self.init_flat = True
tsq = JobQueue().queue
class CreateVmachineInCelery(CreateVmachine):
def __init__(self, auth, body):
super().__init__(auth, body)
@property
def logger(self):
return logging
def consume_job():
while True:
if tsq.empty():
logging.info("empty queue,waiting for job..")
else:
task = tsq.get()
while True:
_resp = CreateVmachineInCelery(task.auth, task.body).install()
_resp = json.loads(_resp.data.decode('UTF-8'))
if _resp.get("error_code") == RET.OK:
tsq.task_done()
break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。