Skip to content

Commit 371f4eb

Browse files
committed
dumper - handle multiple canvases
1 parent e27cf2f commit 371f4eb

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

dump.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
log = logging.getLogger(__name__)
1313
tasks = []
14+
parsers = {}
1415

1516

1617
async def get_meta() -> dict:
@@ -28,18 +29,30 @@ async def push_to_key(redis: aioredis.Redis, key: str, payload: dict, canvas_id:
2829

2930

3031
async def main():
31-
meta = await get_meta()
32-
highest_board = int(meta.get("index", "0"))
33-
log.info(meta)
34-
3532
tasks.append(asyncio.create_task(graphql_parser("config")))
36-
37-
for x in range(0, highest_board + 1):
38-
tasks.append(asyncio.create_task(graphql_parser(x)))
33+
tasks.append(asyncio.create_task(parser_launcher()))
3934

4035
await asyncio.gather(*tasks)
4136

4237

38+
async def parser_launcher():
39+
while True:
40+
meta = await get_meta()
41+
highest_board = int(meta.get("index", "0"))
42+
43+
if len(parsers) < highest_board + 1:
44+
log.info("meta canvas count update, new meta is")
45+
log.info(meta)
46+
47+
for x in range(0, highest_board + 1):
48+
if x not in parsers:
49+
task = asyncio.create_task(graphql_parser(x))
50+
parsers[x] = task
51+
tasks.append(task)
52+
53+
await asyncio.sleep(1)
54+
55+
4356
@backoff.on_exception(backoff.fibo, Exception, max_time=30)
4457
async def graphql_parser(canvas_id):
4558
# pick the corrent gql schema and pick variables for canvas / config grabs.

0 commit comments

Comments
 (0)