-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
36 lines (30 loc) · 1.03 KB
/
main.py
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
31
32
33
34
35
from graph import WikiGraph
import asyncio
import sys
from collections import deque
# main execution of program
# async def main():
# instantiate a left and right graph for source and dest topics
left = WikiGraph()
# right = WikiGraph(is_source=False)
# instantiate coroutines or workers for both graphs
# coros = [right.shortest_path(sys.argv[2], sys.argv[1], left.came_from),
# left.shortest_path(sys.argv[1], sys.argv[2], right.came_from)]
coros = [left.fetcher.worker() for i in range(10)]
# q = deque(coros)
# while q:
# try:
# g = q.popleft()
# ret = await g.__anext__()
# print(ret)
# q.append(g)
# except StopAsyncIteration:
# pass
if __name__ == '__main__':
loop = asyncio.get_event_loop()
# loop.run_until_complete(main())
loop.run_until_complete(asyncio.gather(
left.shortest_path(sys.argv[1], sys.argv[2]),
# right.shortest_path(sys.argv[2], sys.argv[1], left.came_from),
*coros
))