Open ghost opened 10 years ago
Hmm sounds interesting, how about parent process id -> PARALLEL_PPID ?
Sounds like a good idea to me.
I also have a similar use case (each run has the unique lock file that is written by first process and is shared with processes of the same run. Processes of the other run should have another lock file).
this works:
def ppid(pid)
`ps -p #{pid} -o ppid=`.strip
end
ppid(ppid(Process.pid))
but adding the PARALLEL_PID could also be nice, please open a PR if you care :)
It might be a good idea to add an UUID to ENV so that all spawned processes in the same parallel run could see the same UUID. That would enable us to use that UUID for e.g. file locks when something needs to be mutexed between the parallels.
For example, I'm currently writing a parallel-aware formatter for Cucumber which would buffer output for a whole scenario and dump it at each scenario end, but the "dumping" part would have to be in a mutex so that lines don't get mixed up. Or is such a feature already implemented (some ident that all parallels in the same run share, but is different between individual runs)?