1

Two python programs are running locally in my local computer. One program fetch the "price" of share in real-time, and other program need this information asap. The data that I want to share is very small in size (just some numbers).

I tried using SQLite, as it is very fast but it do not support multithreading insert/write etc. What other way I can use to share this information?

Is there some way, I can create a local API or store share prices in "RAM" and access it from another program or something like that?

  • Does this answer your question? [Possible to share in-memory data between 2 separate processes?](https://stackoverflow.com/questions/1268252/possible-to-share-in-memory-data-between-2-separate-processes) – Zeromika Jun 03 '21 at 05:04
  • If the rate of changes is not high, you can just write to disk and watch for changes [1] from another process. [1] https://stackoverflow.com/questions/182197/how-do-i-watch-a-file-for-changes – Jenya Y. Jun 03 '21 at 05:14
  • The prices change in miliseconds. If I use files, one python program might be writing and at the same time, another process is reading it, so reading corrupt file. – Rahul sharma Jun 03 '21 at 05:19
  • @Zeromika Checking – Rahul sharma Jun 03 '21 at 05:19
  • @Zeromika This does not seem to help me. I tried multiprocessing also, but I cannot import one file into another. I am running websockets – Rahul sharma Jun 03 '21 at 06:05
  • 2
    You can use sockets to send data via a local port. Just have your reading program listen on that port and have your writing program send data to it. – CobraPi Jun 03 '21 at 06:07

0 Answers0