Commit Graph

196 Commits

Author SHA1 Message Date
Vincent Driessen 31e492644e Fix year. 2012-03-28 10:49:28 +02:00
Vincent Driessen b0c9ab168d Never refresh when stdout is not a TTY.
This fixes #43.
2012-03-27 12:23:56 +02:00
Vincent Driessen 59aebf8676 Don't filter when no queues are explicitly specified.
This caused the workers from omitting empty queues from workers, as if
they were not listening on them.
2012-03-27 12:17:41 +02:00
Vincent Driessen 2e5f537abd Rewrite rqinfo to start polling by default.
The options to show only partial info (only workers, only queues) are
kept, but not default anymore.  This makes the default invocation
(without args) the most useful one.

The default refresh interval is 2.5 seconds.

This fixes #42.
2012-03-27 11:22:22 +02:00
Vincent Driessen a7c229ddb1 Reflect new API in the RQ scripts. 2012-03-23 15:15:29 +01:00
Vincent Driessen 2982486448 New connection management.
Connections can now be set explicitly on Queues, Workers, and Jobs.
Jobs that are implicitly created by Queue or Worker API calls now
inherit the connection of their creator's.

For all RQ object instances that are created now holds that the
"current" connection is used if none is passed in explicitly.  The
"current" connection is thus hold on to at creation time and won't be
changed for the lifetime of the object.

Effectively, this means that, given a default Redis connection, say you
create a queue Q1, then push another Redis connection onto the
connection stack, then create Q2. In that case, Q1 means a queue on the
first connection and Q2 on the second connection.

This is way more clear than it used to be.

Also, I've removed the `use_redis()` call, which was named ugly.
Instead, some new alternatives for connection management now exist.

You can push/pop connections now:

    >>> my_conn = Redis()
    >>> push_connection(my_conn)
    >>> q = Queue()
    >>> q.connection == my_conn
    True
    >>> pop_connection() == my_conn

Also, you can stack them syntactically:

    >>> conn1 = Redis()
    >>> conn2 = Redis('example.org', 1234)
    >>> with Connection(conn1):
    ...     q = Queue()
    ...     with Connection(conn2):
    ...         q2 = Queue()
    ...     q3 = Queue()
    >>> q.connection == conn1
    True
    >>> q2.connection == conn2
    True
    >>> q3.connection == conn1
    True

Or, if you only require a single connection to Redis (for most uses):

    >>> use_connection(Redis())
2012-03-23 15:10:49 +01:00
Vincent Driessen a662180fd3 Make importlib dependency conditional on the Python version. 2012-03-22 14:51:27 +01:00
Vincent Driessen 6bc173f122 Bugfix. 2012-03-22 14:12:36 +01:00
Vincent Driessen 28216cf63a Implement the requeue_job() top-level API function.
This completely fixes #37.
2012-03-21 15:25:20 +01:00
Vincent Driessen c684949045 Don't expose the FailedQueue class at the top-level.
This fixes #36.
2012-03-21 15:25:03 +01:00
Vincent Driessen 98ea29b15a Don't expose the Job class at the top-level.
This partially fixes #37.
2012-03-21 15:05:58 +01:00
Vincent Driessen 0b837b4b12 Don't warn. In fact, we rely on this the more. 2012-03-21 13:58:37 +01:00
Vincent Driessen 2b6101d110 Move job from Worker to Job test suite. 2012-03-21 13:18:01 +01:00
Vincent Driessen 15342f14d3 Store pickled function calls as strings.
This aids unpacking in the case of a function that isn't importable from
the worker's runtime. The unpickling will now (almost) always succeed,
and throw an ImportError later on, when the function is actually
accessed (thus imported implicitly).

The end result is a job on the failed queue, with exc_info describing
the import error, which is tremendously useful.
2012-03-21 13:09:52 +01:00
Vincent Driessen 14ecb8e956 Add specifics on the "ImportError" to the message in case of an attribute error. 2012-03-16 15:51:46 +01:00
Vincent Driessen be8f7684aa Fix accidentally passing unit test. 2012-03-16 14:21:00 +01:00
Vincent Driessen df2b2838de Merge branch 'timeouts'
This fixes #12.
2012-03-16 10:05:41 +01:00
Vincent Driessen 3c05f20d95 Flake8. 2012-02-24 11:36:33 +01:00
Vincent Driessen 844c5ed8c7 Add @slow wrapper to avoid running slow tests.
Use ./run_tests -f to only run the fast tests.
2012-02-24 07:39:44 +01:00
Vincent Driessen 91fff48389 Flake8. 2012-02-22 18:03:04 +01:00
Vincent Driessen e807748ee6 Test the timing out of jobs.
Really looking for a way to speed up this test.  It takes up a whole
second doing nothing now, really.
2012-02-22 18:01:14 +01:00
Vincent Driessen 9ac9c23412 Flake8. 2012-02-22 17:39:14 +01:00
Vincent Driessen 000849c430 Initialize jobs with timeouts. 2012-02-22 17:36:42 +01:00
Vincent Driessen b8305a818f Safer, and shorter, version of the death penalty.
This case protects against JobTimeoutExceptions being raised immediately
after the job body has been (successfully) executed.  Still,
JobTimeoutExceptions pass through naturally, like any other exception,
to be handled by the default exception handler that writes failed jobs
to the failed queue.

Timeouts therefore are reported like any other exception.
2012-02-22 16:57:13 +01:00
Vincent Driessen 8a856e79ea Initial attempt at job timeouts. 2012-02-22 16:57:11 +01:00
Vincent Driessen f47398a754 Ditch false code size claim. 2012-02-22 10:52:39 +01:00
Vincent Driessen fb587297f6 Requeue should not error when called on a deleted job ID. 2012-02-15 23:09:40 +01:00
Vincent Driessen 7ef3b5ade8 Cleanup job hashes for jobs without result, too. 2012-02-15 22:35:45 +01:00
Vincent Driessen f07d28db86 Organize test fixtures into a separate file. 2012-02-15 21:55:06 +01:00
Vincent Driessen 5717a0ba15 Rename Job.for_call() -> Job.create().
This fixes #34.
2012-02-15 17:01:10 +01:00
Vincent Driessen 7e0b843d06 Implement requeue() method on FailedQueue. 2012-02-15 16:59:27 +01:00
Vincent Driessen 8e85c7eee3 Put Job directly in the top-level `rq` module. 2012-02-15 15:54:02 +01:00
Vincent Driessen 240d2d941d Extracted method.
This makes the act of moving failed jobs to the failed queue
responsibility of the FailedQueue itself, not of the Worker.

This fixes #32.
2012-02-15 15:32:24 +01:00
Vincent Driessen d64ad225eb Make FailedQueue a full subclass of Queue.
We will add special methods on it in the future.

This fixes #33.
2012-02-15 15:30:31 +01:00
Vincent Driessen 6f05e03293 Clean up some of the dummy jobs used for testing.
Also, add a random_failure test.
2012-02-15 14:18:40 +01:00
Vincent Driessen f62e295454 Ignore autoenv file. 2012-02-15 13:15:57 +01:00
Vincent Driessen 06ce9622ea Add compact() method on Queues, to remove dead messages. 2012-02-14 22:55:51 +01:00
Vincent Driessen 80a615a61c Flake8 style fixes. 2012-02-14 22:55:39 +01:00
Vincent Driessen 70cbf00890 Refactor out an exists() and a for_key() method. 2012-02-14 22:52:44 +01:00
Vincent Driessen c49e564d3c Don't break the API when jobs get deleted. 2012-02-14 20:12:26 +01:00
Vincent Driessen bd08f24f15 Cosmetic changes to the command line output. 2012-02-14 17:53:28 +01:00
Vincent Driessen e4055ca42f Allow queues to be emptied. 2012-02-14 17:53:09 +01:00
Vincent Driessen 9e33e1a08f Implement a cancel() method on jobs.
This fixes #29.
2012-02-13 17:32:33 +01:00
Vincent Driessen 53f55ba986 Flake8 style fixes in the test suite. 2012-02-13 17:32:16 +01:00
Vincent Driessen 0a0d9d1ceb Flake8 style fixes. 2012-02-13 17:05:32 +01:00
Vincent Driessen 1a8b80604d Minor refactoring to make the to-failed queue code a bit more readable. 2012-02-13 16:51:47 +01:00
Vincent Driessen 11c7dbb376 Consistently renamed "failure" -> "failed" queue.
Fixes #28.
2012-02-13 16:46:39 +01:00
Vincent Driessen 9f5b1545b6 Fix: store the job result in the correct key.
And expire job hash in Redis after 500 seconds (by default).

Fixes #27.
2012-02-13 16:44:38 +01:00
Vincent Driessen 7bda1ca969 Encapsulate the result property (it should not directly be set). 2012-02-13 16:43:27 +01:00
Vincent Driessen 6266f68310 Style fixes (flake8). 2012-02-13 14:01:15 +01:00