Comments (5)
Here's a library that could be helpful: https://trio.readthedocs.io/en/stable/
from linuxreport.
This might be easy enough: https://docs.python.org/dev/library/concurrent.futures.html#threadpoolexecutor
from linuxreport.
Another way to implement this, would be to split off feed fetching as another service, that would just be sleeping and periodically seeing if any of the URLs are out of date, and and fetching and updating them.
One challenge is that the feed is currently saved in a RAM drive in /tmp, which under systemd is setup as private tmp. This means another service wouldn't be able to access to it. I would have to move it to another directory which can be shared, and hopefully also can be stored in RAM.
Update: systemd lets you join namespaces between two services with "JoinsNamespaceOf'. That would let them share the private tmp directory.
from linuxreport.
I've written an implementation using concurrent.futures and a global threadpool. Now the page worst case time should be the time for the slowest feed, instead of the time to fetch all needed feeds.
from linuxreport.
Here's a test run:
Serially it would take 23 seconds, but with a 10 worker temporary threadpool, it takes 4.
Parsing from remote site http://feeds.feedburner.com/linuxtoday/linux in 0.442090.
Parsing from remote site http://lwn.net/headlines/newrss in 1.406546.
Parsing from remote site http://rss.slashdot.org/Slashdot/slashdotMain in 1.419237.
Parsing from remote site http://www.osnews.com/feed/ in 1.402242.
Parsing from remote site http://news.ycombinator.com/rss in 1.500885.
Parsing from remote site http://lxer.com/module/newswire/headlines.rss in 1.624353.
Parsing from remote site https://www.reddit.com/r/Coronavirus/rising/.rss in 1.667059.
Parsing from remote site http://www.reddit.com/r/linux/.rss in 1.744879.
Parsing from remote site https://www.google.com/alerts/feeds/12151242449143161443/16985802477674969984 in 1.117016.
Parsing from remote site http://www.geekwire.com/feed/ in 3.537120.
Parsing from remote site http://planet.debian.org/rss20.xml in 3.734472.
Parsing from remote site http://www.independent.co.uk/topic/coronavirus/rss in 3.404218.
Fetched all feeds in 4.016407 sec.
from linuxreport.
Related Issues (12)
- Prevent excess RSS requests
- Jitter doesn't work with long page cache expirations HOT 1
- Dark mode
- More URLs HOT 1
- Mobile order HOT 1
- Get rid of mixed-content for SSL
- Add timeout HOT 2
- Smarter refreshing via machine learning
- A few architectural issues
- Use e-tags, last modified headers to be smarter / faster about fetching old content
- Bootstrap / prettier CSS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linuxreport.