# Buggy code
def run(self, **kwargs):
    """Analyze trajectory and produce timeseries"""
    h_list = []
    i = 0
    if self.nproc > 1:
        while i < len(self.universe.trajectory):
            jobs = []
            k = i
            for j in range(self.nproc):
                # start
                print("ts=", i + 1)
                if i >= len(self.universe.trajectory):
                    break
                conn_parent, conn_child = multiprocessing.Pipe(False)
                while True:
                    try:
                        # new thread
                        jobs.append(
                            (
                                multiprocessing.Process(
                                    target=self._HBA,
                                    args=(
                                        self.universe.trajectory[i],
                                        conn_child,
                                        self.universe,
                                        self.selection1,
                                        self.selection2,
                                    ),
                                ),
                                conn_parent,
                            )
                        )
                        break
                    except:
                        print("error in jobs.append")
                jobs[j][0].start()
                i = i + 1

            for j in range(self.nproc):
                if k >= len(self.universe.trajectory):
                    break
                rec01 = jobs[j][1]
                received = rec01.recv()
                h_list.append(received)
                jobs[j][0].join()
                k += 1
        self.timeseries = self._getGraphics(h_list, 0, self.tf - 1, self.dtmax)
    else:
        h_list = MDAnalysis.analysis.hbonds.HydrogenBondAnalysis(
            self.universe, self.selection1, self.selection2, distance=3.5, angle=120.0
        )
        h_list.run(**kwargs)
        self.timeseries = self._getGraphics(
            h_list.timeseries, self.t0, self.tf, self.dtmax
        )


# Traceback (NameError)
ts= 1
ts= 2
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/base.py:116: DeprecationWarning: Setting the following kwargs should be done in the run() method: start, stop
DeprecationWarning)
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/base.py:116: DeprecationWarning: Setting the following kwargs should be done in the run() method: start, stop
DeprecationWarning)
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:650: SelectionWarning: No acceptors found in selection 2. You might have to specify a custom 'acceptors' keyword. Selection will update so continuing with fingers crossed.
warnings.warn(errmsg, category=SelectionWarning)
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:650: SelectionWarning: No donors found in selection 2. You might have to specify a custom 'donors' keyword. Selection will update so continuing with fingers crossed.
warnings.warn(errmsg, category=SelectionWarning)
error
trying again
Process Process-1:
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:650: SelectionWarning: No acceptors found in selection 2. You might have to specify a custom 'acceptors' keyword. Selection will update so continuing with fingers crossed.
warnings.warn(errmsg, category=SelectionWarning)
/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:650: SelectionWarning: No donors found in selection 2. You might have to specify a custom 'donors' keyword. Selection will update so continuing with fingers crossed.
warnings.warn(errmsg, category=SelectionWarning)
Process Process-2:
Traceback (most recent call last):
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/waterdynamics.py", line 659, in _HBA
sys.stdout.flush()
NameError: name 'sys' is not defined
Traceback (most recent call last):
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/waterdynamics.py", line 653, in _HBA
h.run(verbose=verbose)
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py", line 936, in run
verbose=kwargs.get('verbose', False))
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/lib/log.py", line 350, in __init__
assert numsteps > 0, "numsteps step must be >0"
AssertionError: numsteps step must be >0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/biggin/b131/bioc1523/software/anaconda/python3.6/2019.7/envs/all/lib/python3.7/site-packages/MDAnalysis/analysis/waterdynamics.py", line 658, in _HBA
sys.stdout.flush()
NameError: name 'sys' is not defined

# Fixed code
def run(self, **kwargs):
    """Analyze trajectory and produce timeseries"""
    h_list = MDAnalysis.analysis.hbonds.HydrogenBondAnalysis(
        self.universe, self.selection1, self.selection2, distance=3.5, angle=120.0
    )
    h_list.run(**kwargs)
    self.timeseries = self._getGraphics(h_list.timeseries, self.t0, self.tf, self.dtmax)