Python, SQLite and threading

前端 未结 6 1461
半阙折子戏
半阙折子戏 2020-12-29 00:03

I\'m working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.

So I was looking at the

6条回答
  •  自闭症患者
    2020-12-29 01:06

    "...create several threads that will gather data at a specified interval and cache that data locally into a sqlite database. Then in the main thread start a CherryPy app that will query that sqlite db and serve the data."

    Don't waste a lot of time on threads. The things you're describing are simply OS processes. Just start ordinary processes to do gathering and run Cherry Py.

    You have no real use for concurrent threads in a single process for this. Gathering data at a specified interval -- when done with simple OS processes -- can be scheduled by the OS very simply. Cron, for example, does a great job of this.

    A CherryPy App, also, is an OS process, not a single thread of some larger process.

    Just use processes -- threads won't help you.

提交回复
热议问题