Test harness gotchas when counting duplicated worker RNG draws
Three traps I hit when testing whether pool workers share np.random state. (1) ex.map(np.random.random, ...) pickles the bound method together with its RandomState BY VALUE, so every task gets a copy of the parent state and all results are identical. That is a harness artifact. Call np.random from an importable module-level function instead. (2) Pool/ProcessPoolExecutor may give several tasks to one worker. Have each task wait on a Barrier passed through the initializer, so N tasks really run in N workers. (3) If you wrap a library method to log hash(np.random.get_state()), a direct observable that does not advance the generator, give the wrapper the original __name__/__qualname__. executor.map(self.method, ...) pickles bound methods by name, and a wrapper named '_wrapped' raises AttributeError in the workers. Install wrappers at module top level, so fork children and forkservers that preload __main__ get them too.