Spaces:
Runtime error
Runtime error
Commit
·
51507f3
1
Parent(s):
9f475ea
add more
Browse files
app.py
CHANGED
|
@@ -85,6 +85,8 @@ def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
|
| 85 |
|
| 86 |
count += 1
|
| 87 |
if count > 5:
|
|
|
|
|
|
|
| 88 |
return None, "Too many requests, please try again later more."
|
| 89 |
else:
|
| 90 |
count_client_map.put(client_ip, count, 24 * 60 * 60) # 添加一个过期时间为 24 小时的项
|
|
|
|
| 85 |
|
| 86 |
count += 1
|
| 87 |
if count > 5:
|
| 88 |
+
print(client_ip)
|
| 89 |
+
print(count)
|
| 90 |
return None, "Too many requests, please try again later more."
|
| 91 |
else:
|
| 92 |
count_client_map.put(client_ip, count, 24 * 60 * 60) # 添加一个过期时间为 24 小时的项
|
set.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from datetime import datetime, timedelta
|
| 2 |
from collections import defaultdict
|
| 3 |
|
|
@@ -21,3 +22,12 @@ class ExpiringMap:
|
|
| 21 |
def remove(self, key):
|
| 22 |
if key in self.data:
|
| 23 |
del self.data[key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
from datetime import datetime, timedelta
|
| 3 |
from collections import defaultdict
|
| 4 |
|
|
|
|
| 22 |
def remove(self, key):
|
| 23 |
if key in self.data:
|
| 24 |
del self.data[key]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
time_client_map = ExpiringMap()
|
| 29 |
+
time_client_map.put('a', 'b', 10)
|
| 30 |
+
time.sleep(5)
|
| 31 |
+
print(time_client_map.get('a'))
|
| 32 |
+
time.sleep(6)
|
| 33 |
+
print(time_client_map.get('a'))
|