Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added `unfail` method, a couple of formatting changes.

  • Loading branch information...
commit 963f99f9df5e82102515b2b5e0fce0b0c68a679a 1 parent f93086d
Dan Lecocq authored
Showing with 31 additions and 18 deletions.
  1. +5 −1 qless/__init__.py
  2. +1 −1  qless/qless-core
  3. +6 −16 setup.py
  4. +19 −0 test.py
View
6 qless/__init__.py
@@ -166,7 +166,7 @@ def __init__(self, host='localhost', port=6379, hostname=None, **kwargs):
for cmd in [
'cancel', 'config', 'complete', 'depends', 'fail', 'failed', 'get',
'heartbeat', 'jobs', 'peek', 'pop', 'priority', 'put', 'queues',
- 'recur', 'retry', 'stats', 'tag', 'track', 'workers']:
+ 'recur', 'retry', 'stats', 'tag', 'track', 'unfail', 'workers']:
setattr(self, '_%s' % cmd, lua(cmd, self.redis))
def __getattr__(self, key):
@@ -197,6 +197,10 @@ def listen(self, *args, **kwargs):
while True:
self.event(*args, **kwargs)
+ def unfail(self, group, queue, count=500):
+ '''Move jobs from the failed group to the provided queue'''
+ return self._unfail([], [repr(time.time()), group, queue, count])
+
from .lua import lua
from .job import Job, RecurringJob
from .queue import Queue
2  qless/qless-core
@@ -1 +1 @@
-Subproject commit 534fac347c245a9a62100586e8ed662039ec6584
+Subproject commit 0981b97281cf1068c39a8466123e44e068a3df6e
View
22 setup.py
@@ -1,21 +1,10 @@
#! /usr/bin/env python
-try:
- from setuptools import setup
- extra = {
- 'install_requires' : [
- 'argparse', 'hiredis', 'redis', 'psutil', 'simplejson']
- }
-except ImportError:
- from distutils.core import setup
- extra = {
- 'dependencies' : [
- 'argparse', 'hiredis', 'redis', 'psutil', 'simplejson']
- }
+from distutils.core import setup
setup(
name = 'qless-py',
- version = '0.9.3',
+ version = '0.9.4',
description = 'Redis-based Queue Management',
long_description = '''
Redis-based queue management, with heartbeating, job tracking,
@@ -29,16 +18,17 @@
packages = ['qless'],
package_dir = {'qless': 'qless'},
package_data = {'qless': ['qless-core/*.lua']},
- scripts = ['bin/qless-py-worker'],
include_package_data = True,
+ scripts = ['bin/qless-py-worker'],
extras_require = {
'ps': ['setproctitle']
},
+ install_requires = [
+ 'argparse', 'hiredis', 'redis', 'psutil', 'simplejson'],
classifiers = [
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Intended Audience :: Developers',
'Operating System :: OS Independent'
- ],
- **extra
+ ]
)
View
19 test.py
@@ -1047,6 +1047,25 @@ def test_complete_failed(self):
self.assertEqual(job.complete(), 'complete')
self.assertEqual(self.client.jobs[jid].failure, {})
+ def test_unfail(self):
+ # We should be able to unfail jobs in batch. First, fail a large number
+ # of jobs, and then unfail some of them. Make sure that those jobs have
+ # indeed moved, all the remaining failed jobs are still failed, and
+ # that the new jobs can be popped and work like they should
+ jids = [self.q.put(qless.Job, {'test': 'test_unfail'})
+ for i in range(1000)]
+ self.assertEqual(len(
+ [job.fail('foo', 'bar') for job in self.q.pop(1000)]), 1000)
+ self.assertEqual(self.client.unfail('foo', self.q.name, 25), 25)
+ self.assertEqual(self.client.jobs.failed()['foo'], 975)
+ failed = self.client.jobs.failed('foo', 0, 1000)['jobs']
+ self.assertEqual(set([j.jid for j in failed]), set(jids[25:]))
+
+ # Now make sure that they can be popped off and completed correctly
+ self.assertEqual(
+ [j.complete() for j in self.q.pop(1000)],
+ ['complete'] * 25)
+
class TestEverything(TestQless):
def test_config(self):
# Set this particular configuration value
Please sign in to comment.
Something went wrong with that request. Please try again.