def peek(self, count=None): '''Similar to the pop command, except that it merely peeks at the next items''' results = [Job(self.client, **rec) for rec in json.loads( self.client('peek', self.name, count or 1))] if count is None: return (len(results) and results[0]) or None return results
def pop(self, count=None): '''Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.''' results = [Job(self.client, **job) for job in json.loads( self.client('pop', self.name, self.worker_name, count or 1))] if count is None: return (len(results) and results[0]) or None return results
def test_no_mtime(self): '''Don't blow up we cannot check the modification time of a module.''' exc = OSError('Could not stat file') with mock.patch('qless.job.os.stat', side_effect=exc): Job._import('test_job.Foo') Job._import('test_job.Foo')
def test_reload(self): '''Ensure that nothing blows up if we reload a class''' self.client.queues['foo'].put(Foo, {}, jid='jid') self.assertEqual(self.client.jobs['jid'].klass, Foo) Job.reload(self.client.jobs['jid'].klass_name) self.assertEqual(self.client.jobs['jid'].klass, Foo)
def test_reload(self): """Ensure that nothing blows up if we reload a class""" self.client.queues["foo"].put(Foo, {}, jid="jid") self.assertEqual(self.client.jobs["jid"].klass, Foo) Job.reload(self.client.jobs["jid"].klass_name) self.assertEqual(self.client.jobs["jid"].klass, Foo)