crunchdao / crunch-cli

7 stars 4 forks source link

Monkey Patch: `joblib.Parallel._write` is using `.write` which does not flush #132

Open Caceresenzo opened 1 month ago

Caceresenzo commented 1 month ago

For now, this can fix the problem:

import sys

from joblib import Parallel, delayed

def parallel_print(self: Parallel, msg):
    if not self.verbose:
        return

    if self.verbose < 50:
        file = sys.stderr
    else:
        file = sys.stdout

    print(f"[{self}]: {msg}", file=file)

Parallel._print = parallel_print

Parallel(n_jobs=-1, verbose=5)(delayed(sleep)(1) for _ in range(300))