C++ to call python script to handle emailing
On a server I have a C++ program which takes some input and writes some output to a file. After the file is generated, I want to send an email to a person with the corresponding link to the file.
I'd rather avoid dealing with SMTP from C++ itself, so I thought about having C++ using a system call to execute a python script, which would in turn handle the emailing process.
system("python emailer.py email@example.com filetodownload.txt");
import sys email = sys.argv file = sys.argv // handle SMTP emailing...
I have a question about this simple approach. The C++ program is multithreaded, so there may be more than one thread wanting to call the python script to send an email. Is this a concern? Would one (again simple) solution be having a mutex variable in the C++ program which allows only one thread to call the python script at a time? Also, if there are better ways to go about accomplishing this task please let me know.
From what you've shown I don't see any shared resource that would require any multi-threaded synchronisation. Each system call to python will result in a separate process.