本文整理汇总了Python中models.Job.queue方法的典型用法代码示例。如果您正苦于以下问题:Python Job.queue方法的具体用法?Python Job.queue怎么用?Python Job.queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Job
的用法示例。
在下文中一共展示了Job.queue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __queue__
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import queue [as 别名]
def __queue__(self):
''' Starts a job or leaves it in the queue (thread safe) '''
logging.debug("Attempting to acquire queue mutex ...")
self.mutex.acquire()
logging.debug("Successfully acquired queue mutex.")
queue = list(Job.queue()) # Create a copy of the queue
for job in queue:
logging.info("Dispatching job: %s" % job.job_name)
if len(job) == 0:
job.status = u"COMPLETED"
dbsession.add(job)
dbsession.flush()
else:
algo = Algorithm.by_id(job.algorithm_id)
weapon_systems = WeaponSystem.system_ready(algo)
if weapon_systems is not None and 0 < len(weapon_systems):
logging.info("Weapon systems available: %d" % (
len(weapon_systems),
))
thread.start_new_thread(
self.__crack__,
(job, weapon_systems[0],)
)
else:
logging.info("No available weapon systems at this time.")
self.mutex.release()
示例2: check_queue
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import queue [as 别名]
def check_queue(self):
''' Starts a job or leaves it in the queue (thread safe) '''
self.mutex.acquire()
queue = list(Job.queue()) # Create a copy of the queue
for job in queue:
if len(job) == 0:
job.status = u"COMPLETED"
dbsession.add(job)
dbsession.flush()
else:
weapon_systems = WeaponSystem.ready_system(
job.hashes[0].algorithm)
if weapon_systems != None and 0 < len(weapon_systems):
thread.start_new_thread(
self.__crack__, (job, weapon_systems[0],))
self.mutex.release()