Confusion with python's feedparser speed, it's very fast on the command line but slow when im deploying

StackOverflow https://stackoverflow.com/questions/12574275

  •  03-07-2021
  •  | 
  •  

سؤال

feed = feedparser.parse("http://someyoutubeurl")
video_data = feed.entries[0]
# Adding the data to a dict, etc...

This line of code when typed on my python command line instantly runs and finishes. But when i'm deploying feedparser on my django web server, the process literally takes like 10 seconds to complete. Something must be very wrong.

I even tested using the same exact youtube video, and the speed difference was still there!

Do any of you have ideas? Thanks

هل كانت مفيدة؟

المحلول

I am not sure this counts as an answer, but generally there are multiple reasons I see:

  • The hardware of your webserver might not be as powerful as your desktop, so downloading and parsing simply takes longer. If possible you can try the same line of code in your webserver python shell and measure the performance. Downloading depends mainly on your connections speed, parsing mainly on your CPU and partly RAM (depending on the size of the feed).

  • If you running this line of code within Django there will be a slightly bigger delay than when you run if from plain python shell, simple because every action has to go through the Django framework.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top