def _find_next_job(self):
"""Lookup for available jobs to execute"""
with self._ctx:
workers = self._coll.distinct('who')
unused = [pid for pid in workers
if not (pid and psutil.pid_exists(pid))]
job = self._coll.find_one_and_update(
{
'when': {'$lte': datetime.datetime.now()},
'who': {'$in': unused},
},
{
'$set': {'who': os.getpid()}
},
sort=[('when', -1)])
return job
评论列表
文章目录