Skip to content

Commit 44ddcbd

Browse files
committed
fix:error getting scheduler_pid
fix #83
1 parent 4ce4944 commit 44ddcbd

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

docs/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## v1.3.1 🌈
44

5+
### 🐛 Bug Fixes
6+
7+
- Fix workers' page when there are no queues #83
8+
59
### 🧰 Maintenance
610

711
- Removes psycopg2 dependency (#78)

scheduler/rq_classes.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ def _get_property(self, prop_name: str, pipeline: Optional[Pipeline] = None):
146146
connection = pipeline if pipeline is not None else self.connection
147147
return as_text(connection.hget(self.key, prop_name))
148148

149-
def scheduler_pid(self) -> int:
150-
pid = self.connection.get(RQScheduler.get_locking_key(self.queues[0].name))
149+
def scheduler_pid(self) -> Optional[int]:
150+
if len(self.queues) == 0:
151+
logger.warning("No queues to get scheduler pid from")
152+
return None
153+
pid = self.connection.get(DjangoScheduler.get_locking_key(self.queues[0].name))
151154
return int(pid.decode()) if pid is not None else None
152155

153156

scheduler/templates/admin/scheduler/workers-list.partial.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
</a>
4343
</td>
4444
<td>{{ worker.get_state }}</td>
45-
<td>{{ worker.birth_date|date:"Y-m-d, H:i:s" }}</td>
45+
<td>{{ worker.birth_date | date:"Y-m-d, H:i:s" }}</td>
4646
<td>{{ worker.hostname }}</td>
47-
<td>{{ worker.pid|unlocalize }}</td>
48-
<td>{{ worker.total_working_time|default:0|floatformat }}secs</td>
49-
<td>{{ worker.successful_job_count|default:0 }}</td>
50-
<td>{{ worker.failed_job_count|default:0 }}</td>
47+
<td>{{ worker.pid | unlocalize }}</td>
48+
<td>{{ worker.total_working_time | default:0 | floatformat }}secs</td>
49+
<td>{{ worker.successful_job_count | default:0 }}</td>
50+
<td>{{ worker.failed_job_count | default:0 }}</td>
5151
<td>{{ worker | worker_scheduler_pid }}</td>
5252
</tr>
5353
{% endfor %}

0 commit comments

Comments
 (0)