236 Commits (0d69d081264b8465d93d8447853e777e85573a34)

Author SHA1 Message Date
Selwin Ong fd44ad39d4 Python 3 fixes for job dependency stuff. 11 years ago
Selwin Ong fcfe55fe13 Merge branch 'master' into job_dependency
Conflicts:
	rq/job.py
	rq/queue.py
11 years ago
Vincent Driessen 537476b488 PEP8ify. 11 years ago
Sylvain Zimmer a296619074 Split Job.dump() and Job.save() 11 years ago
H. İbrahim Güngör 10bda9684d Pass description parameter to job constructor in order to distinguish job names in queue.jobs or in rq-dashboard. Add related test case. 12 years ago
Alex Morega 328e7611d3 use utf-8 instead of ascii 12 years ago
Alex Morega 8d61d3bf26 port string handling to py3
Redis uses byte values for everything. We save queue names and job
IDs as unicode. So we need to convert every time we get data from redis.
12 years ago
Alex Morega 6eeee85cc3 remove backwards compat for custom properties 12 years ago
Alex Morega a3b5ce5e46 accomodate py3 imports and builtins 12 years ago
Alex Morega a75ea0d693 changes by python-modernize 12 years ago
Selwin Ong 2e826e2b1f Internally renamed the term "parent" to "dependency". 12 years ago
Selwin Ong 0dfb041383 Simplify enqueue_waitlist by using lpop. 12 years ago
Selwin Ong eadc7db29f First stab at writing implementing job dependency. 12 years ago
Selwin Ong a0c9267550 Job.create should also accept arguments in list format. 12 years ago
Vincent Driessen 5a5e14cc70 Merge branch 'hotfix/0.3.7'
Conflicts:
	CHANGES.md
	rq/version.py
12 years ago
Vincent Driessen 66741fff7b Fix bug where workers would not execute builtin functions properly. 12 years ago
Selwin Ong 85e9014296 Moved some logic from worker.perform_job() to job.cleanup(). 12 years ago
Vincent Driessen 501a3870e1 Ignore a job when there isn't a "data" key available. 12 years ago
Vincent Driessen 192770773a Remove unused import. 12 years ago
Vincent Driessen 83525c42c7 Prevent against 'created_at' field being None. 12 years ago
Vincent Driessen 67880343f1 Make inner_exception optional, and use new except syntax. 12 years ago
Idan Kamara 2baa2e370f job: save the real exception when unpickling fails
We raise our own exception which hides the real error (often an ImportError),
making it difficult to see what happend. Instead, save the original exception
too.
12 years ago
Vincent Driessen 90b15fd0b6 Don't silently fail when unpickling.
When a pickled job string can't be unpickled because some required
module isn't loadable, this leads to an `UnpickleError` in the worker
(not in the horse).

Currently we just assume "garbage" in the job's data field, and silently
ignore it.

This is bad.

Really bad.

Because it avoids the normal exception handling mechanism that RQ has.

Historically, this "feature" was introduced to ignore any invalid pickle
data ("bad strings") on queues, and go on. However, we must assume data
inside `job.data` to be valid pickle data.

While an invalid _format_ of pickle data (e.g. the string "blablah"
isn't valid) leads to unpickle errors, unpickling errors will also occur
when the job can't be validly constructed in memory for other reasons,
like being unable to load a specific class.

Django is a good example of this: try submitting jobs that use
`django.conf.settings` while the `DJANGO_SETTINGS_MODULE` env var isn't
set. Currently, RQ workers will drop these jobs and dismiss them like
any non-valid pickle data. You won't be notified.

This patch changes RQ's behaviour to never ignore invalid string data on
any queue and _always_ handle these errors explicitly (but without
bringing the main loop down, of course).
12 years ago
Vincent Driessen 10237ddcb4 Merge branch 'job-access-within-job'
Conflicts:
	CHANGES.md
	rq/job.py
12 years ago
Timo Steidle 881b944283 Changed status "Running" into "started" to be more consistent with the other statuses 12 years ago
Timo Steidle 8787cfbb30 Added new job status "Running" 12 years ago
Vincent Driessen 7ff6ed72da Add backward compat (will be removed in 0.4).
This is to support users that are relying on the current custom property
implementation.  A warning will be displayed on the console, stating
that this support will be removed from RQ version 0.4.
12 years ago
Vincent Driessen 8cb6a21670 Only store custom properties when they're written to the meta dict. 12 years ago
Vincent Driessen 4b66d7af41 Merge branch 'master' into job-access-within-job
Conflicts:
	rq/job.py
12 years ago
Vincent Driessen 8581cd6463 Don't allow jobs without Redis connection.
And other connection-related fixes.
12 years ago
Vincent Driessen 95d3aed98e Store the job ID on the internal stack.
It does so instead of the instance itself.  Still returns the job---the
interface hasn't changed.
12 years ago
Vincent Driessen 372de4b45a Implement the get_current_job() function.
This fixes #125.
12 years ago
Vincent Driessen 781f3e0460 Add test for custom exc handling. 12 years ago
Vincent Driessen a017756748 Fetch fresh status value on every request.
It could probably require a bit of caching, to prevent too many fetches
per time slot (for example, return the locally cached value if that
value is as fresh as a second or so).

This fixes #120.
13 years ago
Vincent Driessen 6b0ebe9ceb Remove is_done property.
It is too similar to is_finished.
13 years ago
Vincent Driessen 9549b34d60 Add convenience accessor properties for status. 13 years ago
Vincent Driessen 4224304291 I like this implementation of an 'enum' better. 13 years ago
Selwin Ong 442b389b97 Job returning None as result are now persisted correctly.
Job status can now be checked via ``status`` property which should
return either "queued", "finished" or "failed".
13 years ago
Vincent Driessen f06ef9c975 Merge branch 'selwin-async-2'
This fixes #114.
13 years ago
Vincent Driessen e2a0d83eee Whoops. 13 years ago
Vincent Driessen 83369f3b9b Prefer `result` over `return_value`.
`return_value` still is available as a backward-compatible accessor.

This fixes #116.
13 years ago
Selwin Ong 06d75630e0 Execute job immediately if Queue(async=False) 13 years ago
Selwin Ong a5e6765990 Added "result_ttl" property on jobs that determines how long job results are persisted in Redis. 13 years ago
Vincent Driessen f6e67431d7 Refactor the .enqueue() API to not gobble the timeout kwargs.
This fixes #98.
13 years ago
Vincent Driessen 8436d9b2c8 PEP8ify. 13 years ago
Vincent Driessen 1a178d673b Fix bug where results wasn't correctly unpickled when refreshing from Redis. 13 years ago
Vincent Driessen a032896453 Add means of specifying the job function using strings. 13 years ago
Vincent Driessen 074af72536 Minor fix for empty dict check. 13 years ago
Selwin Ong 809874ee83 Don't store Job's "_instance" attribute in Redis. 13 years ago
Vincent Driessen 604fce99a1 Merge with master. 13 years ago
Selwin Ong 1fb0a1bfac Modified ``Job`` ``save`` and ``refresh`` methods to support persisting
additional ``Job`` attributes into Redis.
13 years ago
Omar Khan 03bd49511d Allow instance methods to be enqueued
Only works for picklable instances
13 years ago
mattdennewitz 9f2f9e367c Class methods now use given "cls" 13 years ago
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())
13 years ago
Vincent Driessen 6bc173f122 Bugfix. 13 years ago
Vincent Driessen 28216cf63a Implement the requeue_job() top-level API function.
This completely fixes #37.
13 years ago
Vincent Driessen 98ea29b15a Don't expose the Job class at the top-level.
This partially fixes #37.
13 years ago
Vincent Driessen 0b837b4b12 Don't warn. In fact, we rely on this the more. 13 years ago
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.
13 years ago
Vincent Driessen 14ecb8e956 Add specifics on the "ImportError" to the message in case of an attribute error. 13 years ago
Vincent Driessen 000849c430 Initialize jobs with timeouts. 13 years ago
Vincent Driessen 8a856e79ea Initial attempt at job timeouts. 13 years ago
Vincent Driessen 5717a0ba15 Rename Job.for_call() -> Job.create().
This fixes #34.
13 years ago
Vincent Driessen 70cbf00890 Refactor out an exists() and a for_key() method. 13 years ago
Vincent Driessen 9e33e1a08f Implement a cancel() method on jobs.
This fixes #29.
13 years ago
Vincent Driessen 7bda1ca969 Encapsulate the result property (it should not directly be set). 13 years ago
Vincent Driessen 6266f68310 Style fixes (flake8). 13 years ago
Vincent Driessen 8da204f74a Always use cPickle, never 'regular' pickle.
This fixes #18.
13 years ago
Vincent Driessen 9318825429 Abstract away from the concrete pickle implementation.
Choose cPickle, if available, for best performance.
13 years ago
Vincent Driessen 791f8169f5 Remove dead code. 13 years ago
Vincent Driessen 7c903e45ef Simplify the persistence of jobs.
Fixes #23 and #24.
13 years ago
Vincent Driessen bffe6cbbde Encapsulate internal function call representation.
This means it's not allowed anymore to directly set func, args, and
kwargs.  Instead, use the for_call() constructor.
13 years ago
Vincent Driessen 370399f8f7 CHECKPOINT: dequeue_any now returns the queue that was popped from. 13 years ago
Vincent Driessen b1650cb9b9 CHECKPOINT: Second part of the big refactoring.
Jobs are now stored in separate keys, and only job IDs are put on Redis
queues.  Much of the code has been hit by this change, but it is for the
good.

No really.
13 years ago
Vincent Driessen 65105b44c3 CHECKPOINT: Initial part of the big refactor. 13 years ago
Vincent Driessen 20e908039f Initially set the exc_info property, so it does not raise an
AttributeException when accessed.
13 years ago
Vincent Driessen fdce187c27 Putting failed jobs on the failure queue. 13 years ago
Vincent Driessen 7eb8d92605 Put unreadable tasks on the failure queue. 13 years ago
Vincent Driessen 0be1cb6ac0 Change the way jobs are pickled.
There is no job tuple anymore, but instead Jobs are picklable by
themselves natively.  Furthermore, I've added a way to annotate Jobs
with created_at and enqueued_at timestamps, to drive any future Job
performance stats.  (And to enable requeueing, while keeping hold of the
queue that the Job originated from.)

This fixes #17.
13 years ago
Vincent Driessen 0503eb2829 Clarified responsibility of the Job class.
The Job itself has nothing to do with queueing and dequeueing, so the
DequeueError wasn't appropriate here, either.
13 years ago
Vincent Driessen db5753b0d6 Put Job in its own file. 13 years ago
Vincent Driessen 1c9fa66bc1 Greatly simplify the setup.
Jobs don't even need to be tagged.  Any function can be put on queues.
13 years ago
Vincent Driessen 196a9815d2 Add dequeue method to Queue. 13 years ago
Vincent Driessen b5e0377eb0 Allow jobs to be declared without a default queue.
This makes it impossible to use delay() on them.  Instead, you should
use enqueue().
13 years ago
Vincent Driessen 407f3e8b38 Add ability to put work on alternate queues. 13 years ago
Vincent Driessen d721f0708b Refactor the whole Redis connection stuff to be just as easy as in RDB. 13 years ago