Changeset 962


Ignore:
Timestamp:
06/26/20 17:17:21 (4 years ago)
Author:
Maciej Komosinski
Message:

Added an optional parameter: unique process ID. Only relevant when you run multiple instances of this class simultaneously but as separate processes, and they use the same Framsticks CLI executable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/FramsticksCLI.py

    r961 r962  
    4848
    4949
    50         def __init__(self, framspath, framsexe):
     50        def __init__(self, framspath, framsexe, pid=""):
     51                self.pid = pid if pid is not None else ""
    5152                self.id = next(FramsticksCLI._next_instance_id)
    5253                self.frams_path = framspath
     
    111112        def __getPrefixedFilename(self, filename: str) -> str:
    112113                # Returns filename with unique instance id appended so there is no clash when many instances of this class use the same Framsticks CLI executable
    113                 return FramsticksCLI.FILE_PREFIX + str(chr(ord('A') + self.id)) + '_' + filename
     114                return FramsticksCLI.FILE_PREFIX + self.pid + str(chr(ord('A') + self.id)) + '_' + filename
    114115
    115116
     
    243244        parser.add_argument('-exe', required=False, help='Executable name. If not given, "frams.exe" or "frams.linux" is assumed.')
    244245        parser.add_argument('-genformat', required=False, help='Genetic format for the demo run, for example 4, 9, or S. If not given, f1 is assumed.')
     246        parser.add_argument('-pid', required=False, help='Unique ID of this process. Only relevant when you run multiple instances of this class simultaneously but as separate processes, and they use the same Framsticks CLI executable. This value will be appended to the names of created files to avoid conflicts.')
    245247        return parser.parse_args()
    246248
     
    266268
    267269        parsed_args = parseArguments()
    268         framsCLI = FramsticksCLI(parsed_args.path, parsed_args.exe)
     270        framsCLI = FramsticksCLI(parsed_args.path, parsed_args.exe, parsed_args.pid)
    269271
    270272        simplest = framsCLI.getSimplest('1' if parsed_args.genformat is None else parsed_args.genformat)
Note: See TracChangeset for help on using the changeset viewer.