How do I notify a process of an SQLite database change done in a different process?

前端 未结 7 2544
南笙
南笙 2021-02-19 16:27

Let\'s say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes.

The \"player\" process reads the database

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 17:23

    Edit: I am asuming processes on the same machine.

    In my opinion there are two ways:

    • Polling (as you mentioned), but keep it to a single value (like a table that just keeps the LastUpdateTime of other tables)

    • Use whichever interprocess-communication there is available on the target platform. This could be events in Windows (e.g. in C# (I don't know in Python) the ManualResetEvent, AutoResetEvent, or a Mutex if you want to sacrifice a waiter-thread in each process), or Signals in Linux.

提交回复
热议问题