fix: 发布机500 (#11841)

Co-authored-by: feng <1304903146@qq.com>
pull/11846/head
fit2bot 1 year ago committed by GitHub
parent ac11790192
commit f55c84ce3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save