From e86fb5736626bf4262051f9d8c4badd72b9b7af0 Mon Sep 17 00:00:00 2001 From: Paul Robertson Date: Tue, 7 Aug 2018 19:41:15 -0400 Subject: [PATCH] add is_async property to queue (#982) --- rq/queue.py | 5 +++++ tests/test_queue.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/rq/queue.py b/rq/queue.py index 84a938a..3aea012 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -130,6 +130,11 @@ class Queue(object): """Returns whether the current queue is empty.""" return self.count == 0 + @property + def is_async(self): + """Returns whether the current queue is async.""" + return bool(self._is_async) + def fetch_job(self, job_id): try: job = self.job_class.fetch(job_id, connection=self.connection) diff --git a/tests/test_queue.py b/tests/test_queue.py index a2ca8c8..2407c28 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -651,6 +651,13 @@ class TestFailedQueue(RQTestCase): self.assertEqual(job.return_value, 6) self.assertNotEqual(self.testconn.ttl(job.key), -1) + def test_is_async(self): + """Queue exposes is_async as a property.""" + inline_queue = Queue(is_async=False) + self.assertFalse(inline_queue.is_async) + async_queue = Queue(is_async=True) + self.assertTrue(async_queue.is_async) + def test_custom_job_class(self): """Ensure custom job class assignment works as expected.""" q = Queue(job_class=CustomJob)