Update ccc.py
Browse files
ccc.py
CHANGED
@@ -149,7 +149,7 @@ async def print_status_periodically():
|
|
149 |
print("Working")
|
150 |
await asyncio.sleep(60)
|
151 |
|
152 |
-
async def
|
153 |
initialize_base_ids()
|
154 |
tasks = []
|
155 |
instances_per_digit = 20000
|
@@ -161,26 +161,9 @@ async def scanner_main():
|
|
161 |
tasks.append(print_status_periodically())
|
162 |
await asyncio.gather(*tasks)
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
asyncio.
|
167 |
-
|
168 |
-
scanner_task = loop.create_task(scanner_main())
|
169 |
-
api_task = loop.create_task(
|
170 |
-
uvicorn.run(
|
171 |
-
app,
|
172 |
-
host="0.0.0.0",
|
173 |
-
port=7860,
|
174 |
-
loop=loop
|
175 |
-
)
|
176 |
-
)
|
177 |
-
|
178 |
-
try:
|
179 |
-
loop.run_forever()
|
180 |
-
except KeyboardInterrupt:
|
181 |
-
pass
|
182 |
-
finally:
|
183 |
-
loop.close()
|
184 |
|
185 |
if __name__ == "__main__":
|
186 |
-
|
|
|
149 |
print("Working")
|
150 |
await asyncio.sleep(60)
|
151 |
|
152 |
+
async def start_scanner():
|
153 |
initialize_base_ids()
|
154 |
tasks = []
|
155 |
instances_per_digit = 20000
|
|
|
161 |
tasks.append(print_status_periodically())
|
162 |
await asyncio.gather(*tasks)
|
163 |
|
164 |
+
@app.on_event("startup")
|
165 |
+
async def startup_event():
|
166 |
+
asyncio.create_task(start_scanner())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
if __name__ == "__main__":
|
169 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|