In general, I would suggest that the worker processes send messages to a RemoteChannel on the the master process, and let the master process do I/O (in an asynchronous Task). This serializes the output without involving file locking. It is also advantageous because in some cluster situations, worker processes may not even have access to the file system, and even if you have a distributed filesystem, locking is very tricky. It also allows the “file” to be something else, like a pipe or a terminal.
2 Likes