aboutsummaryrefslogtreecommitdiff
path: root/src/manager.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2019-05-21 23:49:03 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2019-05-21 23:49:03 +0200
commit7d9bc6621eea035034cd56d20de9333f09387940 (patch)
treed9b985163e990012987b64c7d563c5110a9ff0ca /src/manager.py
parentMerge branch 'master' of gitlab.com:newspipe/newspipe (diff)
downloadnewspipe-7d9bc6621eea035034cd56d20de9333f09387940.tar.gz
newspipe-7d9bc6621eea035034cd56d20de9333f09387940.tar.bz2
newspipe-7d9bc6621eea035034cd56d20de9333f09387940.zip
Improved crawler.
Diffstat (limited to 'src/manager.py')
-rwxr-xr-xsrc/manager.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/manager.py b/src/manager.py
index 795b3974..244ab77f 100755
--- a/src/manager.py
+++ b/src/manager.py
@@ -65,16 +65,19 @@ def fetch_asyncio(user_id=None, feed_id=None):
feed_id = int(feed_id)
except:
feed_id = None
+
+
+ loop = asyncio.get_event_loop()
+ queue = asyncio.Queue(maxsize=2, loop=loop)
+
+ producer_coro = default_crawler.retrieve_feed(queue, users, feed_id)
+ consumer_coro = default_crawler.insert_articles(queue, 1)
logger.info('Starting crawler.')
-
start = datetime.now()
- loop = asyncio.get_event_loop()
- for user in users:
- default_crawler.retrieve_feed(loop, user, feed_id)
- loop.close()
+ loop.run_until_complete(asyncio.gather(producer_coro, consumer_coro))
end = datetime.now()
-
+ loop.close()
logger.info('Crawler finished in {} seconds.' \
.format((end - start).seconds))
bgstack15