SimulatorProcess requires it's worker number to be defined, but also defines a default value. Since SimulatorProcess inherits from ServerProcess and we do not wish to change the signature of ServerProcess, SimulatorProcess should throw an exception in it's constructor if worker_number is undefined.
Created attachment 303089 [details] Patch
Comment on attachment 303089 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=303089&action=review > Tools/Scripts/webkitpy/port/simulator_process.py:61 > + if not worker_number is None: > + raise Exception('worker_number must be defined when initializing {}'.format(self.__class__.__name__)) We should remove the default value for worker_number from the function signature such that it read: def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, worker_number): Then we can remove this code. Instantiating a SimulatorProcess without a worker_number will raise a Python TypeError.
Comment on attachment 303089 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=303089&action=review >> Tools/Scripts/webkitpy/port/simulator_process.py:61 >> + raise Exception('worker_number must be defined when initializing {}'.format(self.__class__.__name__)) > > We should remove the default value for worker_number from the function signature such that it read: > > def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, worker_number): > > Then we can remove this code. Instantiating a SimulatorProcess without a worker_number will raise a Python TypeError. You can not have a function argument which requires a value after ones which define default ones in Python. I don't think we want to do the refactor to change the signature of ServerProcess's initializer because I've seen commands like this: ServerProcess(port, 'Example Process', ['ls'], environment) throughout webkitpy. If we want an exception thrown as early as possible, I think raising an exception here is the best technique. Otherwise, we could just allow the undefined worker_number to fail later, which would be with a Python exception as well when we attempt to access the device_for_worker_number_map.