Update ccc.py
Browse files
ccc.py
CHANGED
|
@@ -1,32 +1,15 @@
|
|
| 1 |
import aiohttp
|
|
|
|
| 2 |
import asyncio
|
| 3 |
import random
|
| 4 |
import multiprocessing
|
| 5 |
from dateutil import parser
|
| 6 |
import os
|
| 7 |
import logging
|
| 8 |
-
from fastapi import FastAPI
|
| 9 |
-
import uvicorn
|
| 10 |
-
from contextlib import asynccontextmanager
|
| 11 |
|
| 12 |
# Disable all logging except for critical errors
|
| 13 |
logging.basicConfig(level=logging.CRITICAL)
|
| 14 |
|
| 15 |
-
@asynccontextmanager
|
| 16 |
-
async def lifespan(app: FastAPI):
|
| 17 |
-
# Startup
|
| 18 |
-
initialize_base_ids()
|
| 19 |
-
asyncio.create_task(start_scanner())
|
| 20 |
-
yield
|
| 21 |
-
# Shutdown
|
| 22 |
-
# Add any cleanup code here if needed
|
| 23 |
-
|
| 24 |
-
app = FastAPI(lifespan=lifespan)
|
| 25 |
-
|
| 26 |
-
@app.get("/")
|
| 27 |
-
async def root():
|
| 28 |
-
return {"status": "running"}
|
| 29 |
-
|
| 30 |
discord_webhook_url = os.environ['webhook']
|
| 31 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
| 32 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
|
@@ -159,16 +142,21 @@ async def print_status_periodically():
|
|
| 159 |
print("Working")
|
| 160 |
await asyncio.sleep(60)
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
instances_per_digit = 20000
|
| 165 |
|
| 166 |
for i in range(instances_per_digit):
|
| 167 |
digit = 7 + (i % 8)
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
await asyncio.gather(*tasks)
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import aiohttp
|
| 2 |
+
import time
|
| 3 |
import asyncio
|
| 4 |
import random
|
| 5 |
import multiprocessing
|
| 6 |
from dateutil import parser
|
| 7 |
import os
|
| 8 |
import logging
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Disable all logging except for critical errors
|
| 11 |
logging.basicConfig(level=logging.CRITICAL)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
discord_webhook_url = os.environ['webhook']
|
| 14 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
| 15 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
|
|
|
| 142 |
print("Working")
|
| 143 |
await asyncio.sleep(60)
|
| 144 |
|
| 145 |
+
def run_scanner_in_process(digit):
|
| 146 |
+
asyncio.run(run_scanner_instance(digit))
|
| 147 |
+
|
| 148 |
+
if __name__ == "__main__":
|
| 149 |
+
initialize_base_ids()
|
| 150 |
+
processes = []
|
| 151 |
instances_per_digit = 20000
|
| 152 |
|
| 153 |
for i in range(instances_per_digit):
|
| 154 |
digit = 7 + (i % 8)
|
| 155 |
+
process = multiprocessing.Process(target=run_scanner_in_process, args=(digit,))
|
| 156 |
+
processes.append(process)
|
| 157 |
+
process.start()
|
|
|
|
| 158 |
|
| 159 |
+
asyncio.run(print_status_periodically())
|
| 160 |
+
|
| 161 |
+
for process in processes:
|
| 162 |
+
process.join()
|