279 Commits (83f81b351d5a62b016111c1742d0fa7dd2c772c0)

Author SHA1 Message Date
Javier Lopez fc5295edfc Set busy state on parent while waiting for horse 10 years ago
glaslos 55c541bc59 added job ttl to queue.enqueue() 10 years ago
Bradley Young 5caccaabfe Adding optional list handling to the exc_handler option in Worker.
Adding command line --exception_handler option (with multiple entries allowed) to `rq worker`
Added tests for command line options.
10 years ago
Nic Cope de0b501823 Pass the default worker connection into the started and finished registries
In practice all the registry methods are called with pipelines, but if no
connection is passed in when instantiating the registry and the connection
stack is empty resolve_connection will raise NoRedisConnectionException.
10 years ago
Selwin Ong 2307bc8253 Added FinishedJobRegistry to monitor finished jobs. 10 years ago
Vincent Driessen 783b6f9ec7 Fix PEP8 complaint. 10 years ago
Vincent Driessen 7686785d61 Merge branch 'selwin-working-queue'
Conflicts:
	tests/test_worker.py
10 years ago
Vincent Driessen 4b7c59d68d Fix PEP8 complaints. 10 years ago
Selwin Ong 9341a4a33d Renamed WorkingQueue to StartedJobRegistry. 10 years ago
Selwin Ong 60c7a3cc6e working_queue.remove call should be pipelined. 10 years ago
Selwin Ong 4d90cc062e Add job to WorkingQueue before execution and remove from WorkingQueue after. 10 years ago
Selwin Ong b0c0a84ab0 Moved some logic into worker.prepare_job_execution to make things testable. 10 years ago
foxx 52c3ad0fbf Renamed to SimpleWorker 10 years ago
foxx 16ee71f26d Use class for test worker, and performs PID check in unit tests, #412 10 years ago
Selwin Ong 7cf8ef42d1 Don't pass "args" into logging call. 10 years ago
Selwin Ong b05c2052e1 Capture more data when logging errors. 11 years ago
Vincent Driessen 865efd6e8c Leave setting the state to the worker, not the Job itself.
Should fix #389.
11 years ago
Vincent Driessen d37f49f643 Merge branch 'andrewsg-warnings' 11 years ago
Selwin Ong 7ac1c3500a Worker.__init__ should accept custom job class. 11 years ago
Andrew Gorcester 17a4ed056d use warnings.warn() instead of raise for DeprecationWarning 11 years ago
Vincent Driessen 83382f51d0 PEP8ify. 11 years ago
Vincent Driessen c263f8f600 Fix regression introduced in 0.4.3. 11 years ago
Vincent Driessen b048e23875 Merge pull request #342 from friedcell/master
make job class dynamic
11 years ago
Vincent Driessen ab9e6b852e Fix PEP8 complaints. 11 years ago
Vincent Driessen 38ec259b6e Enable the most modern Python syntax. 11 years ago
Marko Mrdjenovic 5cba260cca Job and Queue classes as variables (compatible with existing naming) 11 years ago
Tomas Hanacek 6494233058 rqworker default arguments of socket, worker_ttl, results_ttl bugfix 11 years ago
Selwin Ong 7eb6c2ab9f Job timeouts are now handled by "worker.death_penalty_class". 11 years ago
Selwin Ong 835c353380 Job status should be updated during job.perform(). 11 years ago
Selwin Ong 57990fa052 Simplify worker.work() by moving some functionalities to relevant methods. 11 years ago
Selwin Ong f5c3c9a6dd Deprecate job.status. 11 years ago
Selwin Ong 72457d2286 Added DeprecationWarning to worker.state. 11 years ago
Selwin Ong 2fe5d9e25e Python 3 compatibility with worker.get_current_job(). 11 years ago
Selwin Ong 802ecb5ccb Renamed worker.set_job_id() and worker.get_job_id() for consistency. 11 years ago
Selwin Ong 93bb9ec5f4 Added tests for worker.get_current_job(). 11 years ago
Selwin Ong 1b3832adb5 Merge branch 'master' of https://github.com/mbr/rq into worker-get_job_id
Conflicts:
	rq/worker.py
11 years ago
Selwin Ong 37376cfe42 Deprecate worker.state. 11 years ago
Selwin Ong 2044e790f5 Renamed Worker.fork_and_perform_job to Worker.execute_job. 11 years ago
Marc Brinkmann e81ee5b672 Update worker.py
Use docstring instead of comment. Sorry.
11 years ago
Vincent Driessen d0381e98ee Fix .pipeline -> ._pipeline.
This makes sure it's compatible with both Redis and StrictRedis back
ends.
11 years ago
Dj Gilcrease fd036538f7 Wrap the perform_job try/except in a pipeline context so the pipeline connection is properly refrshed after the work is done 11 years ago
Malthe Borch ba0b39a43b Unpickle job data lazily. This fixes issue #294. 11 years ago
Vincent Driessen 888d771d4d Merge pull request #287 from malthe/shed-times-dependency
Remove dependency on 'times' library (issue #286).
11 years ago
Vincent Driessen e1e2405150 Merge branch 'hotfix-0.3.13'
Conflicts:
	CHANGES.md
11 years ago
Vincent Driessen b52089ede1 Fix NameError.
This was the result of a faulty merge. I'm sorry.
11 years ago
Vincent Driessen cf98591ca5 Merge branch 'hotfix-0.3.12'
Conflicts:
	CHANGES.md
	rq/worker.py
11 years ago
Vincent Driessen d0fa35dc66 Python 2.6 fix. 11 years ago
Vincent Driessen 8414a67d65 Fix bug where worker died from monitoring views.
Fixes #288.

Conflicts:
	rq/worker.py
11 years ago
Malthe Borch c5a381fbe9 Remove dependency on 'times' library (see issue #286).
Basically, for the functionality needed, a dependency on 'times' (which
in turn depends on 'python-dateutil') seem unnecessary.
11 years ago
Vincent Driessen 9abbfc4dfb Use kwarg to specify connection. 11 years ago
Malthe Borch 1792a194bd Should pass a connection here because we might not be using a connection stack. 11 years ago
Joshua Chia ef2bbe762b Minor cleanup: Use Status enums instead of strings 11 years ago
reterVision c27cb5217c Remove duplicate function call. 11 years ago
Marc Brinkmann 3d0138d319 Added Worker.get_current_job() convenience method. 11 years ago
Marc Brinkmann c745f6811a Added job_id property, storing the id of the currently executing job. 11 years ago
Marc Brinkmann 606d4fa10f Add optional pipeline parameter to set_state. 11 years ago
Vincent Driessen 7fdd115e28 Merge branch 'jchia-master'
Conflicts:
	rq/job.py
	rq/queue.py
11 years ago
Vincent Driessen bb3dc5b0b2 Terminology change: waitlist -> dependents. 11 years ago
Joshua Chia b89d6c8990 Set timeout at Job creation instead of during enqueueing; made Queue.enqueue_call respect `timeout` when `after` is specified 11 years ago
Vincent Driessen 4dbbfc1d8f Merge pull request #252 from nvie/use-utc
Store birth and death values as UTC dates
11 years ago
Selwin Ong fcfe55fe13 Merge branch 'master' into job_dependency
Conflicts:
	rq/job.py
	rq/queue.py
11 years ago
Vincent Driessen aefa44b30c Store birth and death values as UTC dates. 11 years ago
Vincent Driessen 4d92079694 PEP8ify. 11 years ago
Alex Morega 5b630b1e22 port rqinfo to py3 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
Selwin Ong 6550f86646 Don't enqueue waitlisted jobs on failed execution. 12 years ago
Selwin Ong eadc7db29f First stab at writing implementing job dependency. 12 years ago
Vincent Driessen 5289647970 Remove unused import. 12 years ago
Selwin Ong 85e9014296 Moved some logic from worker.perform_job() to job.cleanup(). 12 years ago
Vincent Driessen e0866cdc6c Log the act of sending a heartbeat (DEBUG level). 12 years ago
Vincent Driessen e8c1885eda Avoid negative timeouts when default_worker_ttl is < 60. 12 years ago
Yaniv Aknin 4925b09aa5 Set worker ttl and maintain it when idle/taking/finishing jobs
This change could use far better test coverage, but I'm not sure how to
test it without refactoring more of the code than I think is reasonable
in the scope of this work.
12 years ago
Yaniv Aknin 74c2351232 Refactor dequeue_any to accept arbitrary timeouts
The 'blocking' parameter was replaced with a 'timeout' parameter.

The timeout parameter is interpreted thus:
    0 - no timeout (block forever, equivalent to blocking=True)
    None - non-blocking (return value or None immediately, equivalent to
                         blocking=False)
    <integer> - maximum seconds to block

Upon timing out, a dequeue operation will raise DequeueTimeout.
12 years ago
Vincent Driessen 743cf3cd74 Merge branch 'vierja-ended_time' 12 years ago
Vincent Driessen d1c2b3b78d Merge branch 'selwin-remove-logbook'
Conflicts:
	rq/utils.py
	rq/worker.py
	setup.cfg
	setup.py
12 years ago
Vincent Driessen 37b3bb4bd4 Have Worker.work() setup logging.
Basically, I don't want to enforce users to configure _any_ logging
stack when writing a basic worker, like this:

    from rq import Worker, Queue, Connection

    with Connection():
        q = Queue()
        w = Worker([q])
        w.work(burst=True)

In case you want to disable logging altogether, you can configure your
logging stack to do so.
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
Javier Rey d660b611db ended_at time is now saved when job is finished 12 years ago
Vincent Driessen 9ff5b18ebb Merge branch 'sburns-decorator-ttl' 12 years ago
Vincent Driessen 5e59c6e28e Rename the const. 12 years ago
Scott Burns 538bbb1b55 Decorator accepts result_ttl argument 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 879a87d158 Remove logbook and replace it with logging.
This reverts commit 1ab8c19696 and
reintroduces all changes made by @dstufft.

Still, it needs more patches to reeanble the default log-to-console
behaviour.  See #121.
12 years ago
Vincent Driessen 1ab8c19696 Revert "Remove logbook and replace it with logging".
This reverts the commit range f367c38..978ba2d.

Issue #121 is currently blocking the 0.3.1 release.
12 years ago
Vincent Driessen 781f3e0460 Add test for custom exc handling. 13 years ago
Vincent Driessen db80be4ef7 Fix typos. 13 years ago
Vincent Driessen cdc3a6c7a9 Convenience exc_handler registration in __init__.
Allow custom exception handlers to be passed in in the Worker
constructor.
13 years ago
Vincent Driessen f457bd9da2 Remove incorrect arg to pop_exc_handler method. 13 years ago
Vincent Driessen daa8f38b4b Improve formatting of the exceptions on the console. 13 years ago
Vincent Driessen a20deb2c52 Add custom exception handling capabilities.
This fixes #95.
13 years ago
Vincent Driessen 35761a0d71 Merge branch 'selwin-persist-None-result' 13 years ago
Vincent Driessen bc7e32bae8 Add expiry info to the worker log. 13 years ago
Vincent Driessen 4b797fbf43 Don't use strings, but comments. 13 years ago
Vincent Driessen 4224304291 I like this implementation of an 'enum' better. 13 years ago
Selwin Ong 41946d1bb3 Worker.find_by_key now properly uses connection. 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
Donald Stufft 66235f7ad0 Switch to using slightly more pythonic log code 13 years ago
Vincent Driessen 720011c33e Merge branch 'selwin-result_ttl' 13 years ago
Vincent Driessen a9cb201d39 PEP8ify. 13 years ago
Vincent Driessen 5963ec6d77 Try to make the expiration code a bit more readable. 13 years ago
Vincent Driessen 4b2838943b Rename rv_ttl to default_result_ttl. 13 years ago
Vincent Driessen 78864e2581 PEP8ify. 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 5f4bb8dfc5 Fix word ordering. 13 years ago
Vincent Driessen 1177caf4bf Set state to busy as early as possible. 13 years ago
Vincent Driessen f2d5ebf2fe Merge branch 'master' into selwin-warm-shutdown-2
Conflicts:
	rq/worker.py
13 years ago
Vincent Driessen 1536546613 Worker/horse distinction in signal handler is obsolete. 13 years ago
Vincent Driessen a6bb526773 Fix that doens't abort the currently running job on Ctrl+C. 13 years ago
Vincent Driessen 9bfd686be3 Merge hotfix/0.2.2 13 years ago
Vincent Driessen 4d9881eef2 Print version number when running the server. 13 years ago
Vincent Driessen 1bc0c3d223 Fix bug where pickling the return value caused an uncaught exception. 13 years ago
Selwin Ong a4f1de358f Raise a StopException when Control+C is pressed. 13 years ago
Vincent Driessen 2cb058e91a PEP8ify. 13 years ago
Vincent Driessen 84988bdf94 Fix typo.
This fixes #85.
13 years ago
Vincent Driessen 074d42fe54 Remove strict procname dependency.
This fixes #80.
13 years ago
Selwin Ong 50ba003cee Worker's "all" and "find_by_key" methods should accept "connection" as argument. 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 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 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.
13 years ago
Vincent Driessen 8a856e79ea Initial attempt at job timeouts. 13 years ago
Vincent Driessen 7ef3b5ade8 Cleanup job hashes for jobs without result, too. 13 years ago
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.
13 years ago
Vincent Driessen d64ad225eb Make FailedQueue a full subclass of Queue.
We will add special methods on it in the future.

This fixes #33.
13 years ago
Vincent Driessen bd08f24f15 Cosmetic changes to the command line output. 13 years ago
Vincent Driessen 0a0d9d1ceb Flake8 style fixes. 13 years ago
Vincent Driessen 1a8b80604d Minor refactoring to make the to-failed queue code a bit more readable. 13 years ago
Vincent Driessen 11c7dbb376 Consistently renamed "failure" -> "failed" queue.
Fixes #28.
13 years ago
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.
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 90a458ca8e Add more colorful terminal output.
For better visual parsability.
13 years ago
Vincent Driessen e05acfedce Fix putting jobs on the failure queue when they fail. 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 f516f8df2e CHECKPOINT: Handle failing and unreadable jobs.
Failing (or unreadable) jobs are correctly put on the failure queue by
the worker now.
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 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 5c6f002878 Silently pass when trying to kill child that is already dead.
This fixes #16.
13 years ago
Vincent Driessen 039a132374 Add ellipsis, to indicate we're waiting here. 13 years ago
Vincent Driessen aecb0a1bf0 Simplify calling .work() or .work(burst=True). 13 years ago
Vincent Driessen 636b6690d6 Add the signal name to the debug message. 13 years ago
Vincent Driessen a154ef0bd9 Remove comment.
This ain't the right way to terminate when blocking by pop.
13 years ago
Vincent Driessen 62949c9adb Extra debug output. 13 years ago
Vincent Driessen dde3ea8ef7 Take down horse process when the worker is terminated. 13 years ago
Vincent Driessen 4ac243b3e8 Print what signal was received in a debug statement. 13 years ago
Vincent Driessen 7769d9875f Perform a warm shutdown on SIGTERM, too.
Just like with Ctrl+C (SIGINT), shutdown warmly at first when kill'ed
(SIGTERM).
13 years ago
Vincent Driessen 88cbaa1df9 Slight code reshuffle + added some comments on the construction. 13 years ago