Added logging statements to handle_job_success and handle_job_failure (#1112)

main
Selwin Ong 6 years ago committed by GitHub
parent b14c4e288d
commit f9d42e8a17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -735,6 +735,7 @@ class Worker(object):
3. Setting the workers current job to None 3. Setting the workers current job to None
4. Add the job to FailedJobRegistry 4. Add the job to FailedJobRegistry
""" """
self.log.debug('Handling failed execution of job %s', job.id)
with self.connection.pipeline() as pipeline: with self.connection.pipeline() as pipeline:
if started_job_registry is None: if started_job_registry is None:
started_job_registry = StartedJobRegistry( started_job_registry = StartedJobRegistry(
@ -767,7 +768,7 @@ class Worker(object):
pass pass
def handle_job_success(self, job, queue, started_job_registry): def handle_job_success(self, job, queue, started_job_registry):
self.log.debug('Handling successful execution of job %s', job.id)
with self.connection.pipeline() as pipeline: with self.connection.pipeline() as pipeline:
while True: while True:
try: try:

@ -3,7 +3,7 @@ from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
from tests import RQTestCase from tests import RQTestCase
from tests.fixtures import echo, Number, say_hello from tests.fixtures import echo, say_hello
from rq import Queue from rq import Queue
from rq.exceptions import InvalidJobDependency from rq.exceptions import InvalidJobDependency

@ -644,7 +644,6 @@ class TestWorker(RQTestCase):
# Score in queue is +inf # Score in queue is +inf
self.assertEqual(self.testconn.zscore(registry.key, job.id), float('Inf')) self.assertEqual(self.testconn.zscore(registry.key, job.id), float('Inf'))
def test_work_unicode_friendly(self): def test_work_unicode_friendly(self):
"""Worker processes work with unicode description, then quits.""" """Worker processes work with unicode description, then quits."""
q = Queue('foo') q = Queue('foo')
@ -909,7 +908,7 @@ class TestWorker(RQTestCase):
"""Check that log_job_description True causes job lifespan to be logged.""" """Check that log_job_description True causes job lifespan to be logged."""
q = Queue() q = Queue()
w = Worker([q]) w = Worker([q])
job = q.enqueue(say_hello, args=('Frank',), result_ttl=10) q.enqueue(say_hello, args=('Frank',), result_ttl=10)
w.dequeue_job_and_maintain_ttl(10) w.dequeue_job_and_maintain_ttl(10)
self.assertIn("Frank", mock_logger_info.call_args[0][2]) self.assertIn("Frank", mock_logger_info.call_args[0][2])
@ -918,7 +917,7 @@ class TestWorker(RQTestCase):
"""Check that log_job_description False causes job lifespan to not be logged.""" """Check that log_job_description False causes job lifespan to not be logged."""
q = Queue() q = Queue()
w = Worker([q], log_job_description=False) w = Worker([q], log_job_description=False)
job = q.enqueue(say_hello, args=('Frank',), result_ttl=10) q.enqueue(say_hello, args=('Frank',), result_ttl=10)
w.dequeue_job_and_maintain_ttl(10) w.dequeue_job_and_maintain_ttl(10)
self.assertNotIn("Frank", mock_logger_info.call_args[0][2]) self.assertNotIn("Frank", mock_logger_info.call_args[0][2])

Loading…
Cancel
Save