Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7437786
D763.id2397.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D763.id2397.diff
View Options
diff --git a/swh/scheduler/celery_backend/config.py b/swh/scheduler/celery_backend/config.py
--- a/swh/scheduler/celery_backend/config.py
+++ b/swh/scheduler/celery_backend/config.py
@@ -98,7 +98,8 @@
Arguments:
queue_name: name of the queue to check
- Returns a dictionary raw from the RabbitMQ management API.
+ Returns a dictionary raw from the RabbitMQ management API;
+ or `None` if the current configuration does not use RabbitMQ.
Interesting keys:
- consumers (number of consumers for the queue)
@@ -110,6 +111,9 @@
"""
conn_info = self.connection().info()
+ if conn_info['transport'] == 'memory':
+ # We're running in a test environment, without RabbitMQ.
+ return None
url = 'http://{hostname}:{port}/api/queues/{vhost}/{queue}'.format(
hostname=conn_info['hostname'],
port=conn_info['port'] + 10000,
@@ -125,7 +129,9 @@
def get_queue_length(self, queue_name):
"""Shortcut to get a queue's length"""
- return self.get_queue_stats(queue_name)['messages']
+ stats = self.get_queue_stats(queue_name)
+ if stats:
+ return stats['messages']
INSTANCE_NAME = os.environ.get(CONFIG_NAME_ENVVAR)
diff --git a/swh/scheduler/celery_backend/runner.py b/swh/scheduler/celery_backend/runner.py
--- a/swh/scheduler/celery_backend/runner.py
+++ b/swh/scheduler/celery_backend/runner.py
@@ -50,8 +50,12 @@
if max_queue_length and backend_name in app.tasks:
queue_name = app.tasks[backend_name].task_queue
queue_length = app.get_queue_length(queue_name)
- num_tasks = min(max_queue_length - queue_length,
- MAX_NUM_TASKS)
+ if queue_length is None:
+ # Running without RabbitMQ (probably a test env).
+ num_tasks = MAX_NUM_TASKS
+ else:
+ num_tasks = min(max_queue_length - queue_length,
+ MAX_NUM_TASKS)
else:
num_tasks = MAX_NUM_TASKS
if num_tasks > 0:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 14, 7:33 AM (10 h, 42 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217204
Attached To
D763: Fallback for get_queue_stats() when using memory:// broker.
Event Timeline
Log In to Comment