fix: 发布机500 (#11841)

Co-authored-by: feng <1304903146@qq.com>
This commit is contained in:
fit2bot
2023-10-13 17:19:05 +08:00
committed by GitHub
parent ac11790192
commit f55c84ce3b

View File

@@ -163,7 +163,7 @@ class Applet(JMSBaseModel):
counts[host_id] += 1
hosts = list(sorted(hosts, key=lambda h: counts[h.id]))
return hosts[0]
return hosts[0] if hosts else None
def select_host(self, user, asset):
hosts = self.hosts.filter(is_active=True)
@@ -186,6 +186,8 @@ class Applet(JMSBaseModel):
host = pref_host[0]
else:
host = self._select_by_load(hosts)
if host is None:
return
cache.set(prefer_key, str(host.id), timeout=None)
return host