Python Forum
Multiprocessing doesn't seem to work? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Multiprocessing doesn't seem to work? (/thread-24383.html)

Pages: 1 2


RE: Multiprocessing doesn't seem to work? - t4keheart - Feb-13-2020

(Feb-13-2020, 05:14 PM)DeaD_EyE Wrote: The question is, what happens if receiver runs before sender?
Your problems goes deeper as you think. The whole structure is wrong.

I think a Queue can solve this problems.
Writing to a file and reading it from another process is very fragile.

You're right, I think sub-process is what I really need to be using.

A couple things: I do need a queue feature, I just have no idea how to implement a queue. As the program currently is, anything submitted when my program isn't running simply isn't sent. When I start my program up, it simply pulls the newest submission for both sending & receiving and processes that. So anything that isn't the newest submission is then lost.

But regarding 'what happens if receiver starts before sender'- in the most basic sense, they function independently from one another. Sender takes submissions posted to a table in a db and sends the newest one (checking for new every 1 second)... receiver simply iterates through a list of conversations and checks each one for new replies. They can function on their own if only one is running. However- like you noticed, if the sender isn't running, the list that the receiver reads from and iterates through will not get updated with new conversations to check replies for. But in the end, it doesn't matter which program starts first... just that they're both running.

Though I do recognize that my program, as it currently is, is very fragile and a huge maintenance liability. Basically I'm the only one who would be able to support it just because I'm the one who created it and I know all the things that could go wrong and where to look for issues.

You're right in that I do need to implement queueing, and ditch the reading from/writing to text files.

Also thank you for the input, it really is helpful. As you might have noticed, I'm no dev/python guru... merely trying to get better.