def run(self, duration, obs):
from ecell4_base.core import TimeoutObserver<EOL>timeout = TimeoutObserver(self.__timeout)<EOL>if isinstance(obs, collections.Iterable):<EOL><INDENT>obs = tuple(obs) + (timeout, )<EOL><DEDENT>else:<EOL><INDENT>obs = (obs, timeout)<EOL><DEDENT>p = ProgressBar(**self.__kwargs)<EOL>p.animate(<NUM_LIT:0.0>)<EOL>tstart = self.__sim.t()<EOL>upto = tstart + duration<EOL>while self.__sim.t() < upto:<EOL><INDENT>self.__sim.run(upto - self.__sim.t(), obs)<EOL>p.animate((self.__sim.t() - tstart) / duration, timeout.accumulation())<EOL><DEDENT>if self.__flush:<EOL><INDENT>p.flush()<EOL><DEDENT>else:<EOL><INDENT>print()<EOL><DEDENT>
Run the simulation.

        Parameters
        ----------
        duration : Real
            a duration for running a simulation.
                A simulation is expected to be stopped at t() + duration.
        observers : list of Obeservers, optional
            observers