Update ccc.py
Browse files
ccc.py
CHANGED
@@ -4,6 +4,7 @@ import random
|
|
4 |
from dateutil import parser
|
5 |
import os
|
6 |
import logging
|
|
|
7 |
|
8 |
# Disable all logging except for critical errors
|
9 |
logging.basicConfig(level=logging.CRITICAL)
|
@@ -12,6 +13,8 @@ discord_webhook_url = os.environ['webhook']
|
|
12 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
13 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
14 |
|
|
|
|
|
15 |
async def send_to_discord(session, asset_id, name, creator_id, creator_name, creator_type, asset_type, created_date):
|
16 |
embed = {
|
17 |
"embeds": [
|
@@ -110,10 +113,20 @@ async def run_scanner_instance(digit, semaphore):
|
|
110 |
await asyncio.sleep(1)
|
111 |
|
112 |
async def print_status_periodically():
|
|
|
113 |
while True:
|
114 |
print("Working")
|
|
|
115 |
await asyncio.sleep(60)
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
async def main():
|
118 |
semaphore = asyncio.Semaphore(100) # Limit concurrent tasks
|
119 |
tasks = []
|
@@ -121,6 +134,7 @@ async def main():
|
|
121 |
digit = 7 + (i % 8)
|
122 |
tasks.append(run_scanner_instance(digit, semaphore))
|
123 |
tasks.append(print_status_periodically())
|
|
|
124 |
await asyncio.gather(*tasks)
|
125 |
|
126 |
if __name__ == "__main__":
|
|
|
4 |
from dateutil import parser
|
5 |
import os
|
6 |
import logging
|
7 |
+
import time
|
8 |
|
9 |
# Disable all logging except for critical errors
|
10 |
logging.basicConfig(level=logging.CRITICAL)
|
|
|
13 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
14 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
15 |
|
16 |
+
last_working_time = time.time()
|
17 |
+
|
18 |
async def send_to_discord(session, asset_id, name, creator_id, creator_name, creator_type, asset_type, created_date):
|
19 |
embed = {
|
20 |
"embeds": [
|
|
|
113 |
await asyncio.sleep(1)
|
114 |
|
115 |
async def print_status_periodically():
|
116 |
+
global last_working_time
|
117 |
while True:
|
118 |
print("Working")
|
119 |
+
last_working_time = time.time()
|
120 |
await asyncio.sleep(60)
|
121 |
|
122 |
+
async def check_restart():
|
123 |
+
global last_working_time
|
124 |
+
while True:
|
125 |
+
if time.time() - last_working_time > 180: # 3 minutes
|
126 |
+
print("Restarting due to inactivity")
|
127 |
+
os._exit(1) # Force restart
|
128 |
+
await asyncio.sleep(10)
|
129 |
+
|
130 |
async def main():
|
131 |
semaphore = asyncio.Semaphore(100) # Limit concurrent tasks
|
132 |
tasks = []
|
|
|
134 |
digit = 7 + (i % 8)
|
135 |
tasks.append(run_scanner_instance(digit, semaphore))
|
136 |
tasks.append(print_status_periodically())
|
137 |
+
tasks.append(check_restart())
|
138 |
await asyncio.gather(*tasks)
|
139 |
|
140 |
if __name__ == "__main__":
|