solves multi-process interleaved print problem
(*msgs)
| 51 | |
| 52 | |
| 53 | def printflock(*msgs): |
| 54 | """solves multi-process interleaved print problem""" |
| 55 | with open(__file__, "r") as fh: |
| 56 | fcntl.flock(fh, fcntl.LOCK_EX) |
| 57 | try: |
| 58 | print(*msgs) |
| 59 | finally: |
| 60 | fcntl.flock(fh, fcntl.LOCK_UN) |
| 61 | |
| 62 | |
| 63 | local_rank = int(os.environ["LOCAL_RANK"]) |
no outgoing calls
no test coverage detected