I have been messing around with Multiprocessing on and off for months now trying to figure out an elegant repeatable solution to my issue of wanting multiple processes to write to the same file without messing each other up.
I have used the Multiprocessing Producer/Consumer relationship to overcome these hurdles in the past. Good articles and posts I've found include:
I've tried implementing a function similar to a shared counter described here:
I have become a big fan of the simplicity of the concurrent.Futures ProcessPoolExecutor and using map on each executor as described here:
Tonight, I thought I had found the answer to my search with discovering a module called fasteners for readwrite locks, but apparently this approach only works on threading.
QUESTION: IS there an elegant, simple solution to sharing a lock so that all Processes from ProcessPoolExecutor do not overwrite eachother when writing to a file?
NOTE: I'm writing about 800M rows of ~200 fields to one file using csv.DictWriter. Other recommendations are welcome.