GithubHelp home page GithubHelp logo

Comments (5)

KeithCu avatar KeithCu commented on June 22, 2024

Here's a library that could be helpful: https://trio.readthedocs.io/en/stable/

from linuxreport.

KeithCu avatar KeithCu commented on June 22, 2024

This might be easy enough: https://docs.python.org/dev/library/concurrent.futures.html#threadpoolexecutor

from linuxreport.

KeithCu avatar KeithCu commented on June 22, 2024

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.

KeithCu avatar KeithCu commented on June 22, 2024

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.

KeithCu avatar KeithCu commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.