🐛 Bug: Fix the bug of ZeroDivisionError when the API key does not exist.
Browse files
utils.py
CHANGED
|
@@ -103,6 +103,8 @@ class ThreadSafeCircularList:
|
|
| 103 |
item: 需要冷却的 item
|
| 104 |
cooling_time: 冷却时间(秒),默认60秒
|
| 105 |
"""
|
|
|
|
|
|
|
| 106 |
now = time()
|
| 107 |
async with self.lock:
|
| 108 |
self.cooling_until[item] = now + cooling_time
|
|
@@ -171,6 +173,8 @@ class ThreadSafeCircularList:
|
|
| 171 |
|
| 172 |
async def after_next_current(self):
|
| 173 |
# 返回当前取出的 API,因为已经调用了 next,所以当前API应该是上一个
|
|
|
|
|
|
|
| 174 |
async with self.lock:
|
| 175 |
item = self.items[(self.index - 1) % len(self.items)]
|
| 176 |
return item
|
|
|
|
| 103 |
item: 需要冷却的 item
|
| 104 |
cooling_time: 冷却时间(秒),默认60秒
|
| 105 |
"""
|
| 106 |
+
if item == None:
|
| 107 |
+
return
|
| 108 |
now = time()
|
| 109 |
async with self.lock:
|
| 110 |
self.cooling_until[item] = now + cooling_time
|
|
|
|
| 173 |
|
| 174 |
async def after_next_current(self):
|
| 175 |
# 返回当前取出的 API,因为已经调用了 next,所以当前API应该是上一个
|
| 176 |
+
if len(self.items) == 0:
|
| 177 |
+
return None
|
| 178 |
async with self.lock:
|
| 179 |
item = self.items[(self.index - 1) % len(self.items)]
|
| 180 |
return item
|