Python loop and web server (bottle) in the same script

Chris Angelico rosuav at gmail.com
Thu Nov 23 09:40:33 EST 2017


On Fri, Nov 24, 2017 at 1:27 AM,  <zljubisic at gmail.com> wrote:
> I would like to have a script that collects data every minute and at the same time serve newly collected data as web pages.
>
> Timely collecting data is more important than serving web pages, so collecting data should have priority and should never be interrupted by serving web pages.
>
> Looks like I need some sort of parallelization.

Sounds like you want threads. Spin off a thread that collects data and
sleeps, collects data and sleeps; meanwhile, serve web pages. But
there's no way you can *guarantee* that the serving of pages won't
interrupt data collection. With separate processes, you could
potentially use OS-level prioritization to help your data collection
process, but even then, it's not a guarantee. What are the
consequences of mistimed data collection?

ChrisA



More information about the Python-list mailing list