-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh.py
More file actions
30 lines (20 loc) · 828 Bytes
/
refresh.py
File metadata and controls
30 lines (20 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
from models.event import Event
from models.master import Master
with Master.refresh(bucket="parkrun-au") as master, Pool(20) as pool:
async_events = [
event.get() for event in [
pool.apply_async(
master.refresh_event,
kwds={"bucket": master.bucket, "data": data}
) for data in list(master)
]
]
master.events = [event for event in async_events if isinstance(event, Event)]
exceptions = [event for event in async_events if not isinstance(event, Event)]
if len(exceptions) > 0:
for e in exceptions:
print(e)
raise Exception(f"There were {len(exceptions)} exception(s) found while processing the master refresh")