def _op(self, eager=False):
        self.during_next = True
        while True:
            active = False
            for v in self.iters:
                if not self.final[id(v)]:
                    try:
                        _log.debug("Map%s(func=%s) Next iter: %s" % (("<" + self.name + ">") if self.name else "", self.func.__name__, str(v)))
                        e = v.next()
                        _log.debug("Map%s(func=%s) Next in: %s" % (("<" + self.name + ">") if self.name else "", self.func.__name__, e))
                        self.drawn[id(v)].append(e)
                        active = True
                    except PauseIteration:
                        pass
                    except StopIteration:
                        self.final[id(v)] = True
                    except Exception as e:
                        _log.exception("Map function failed")
                        raise e
            try:
                l = min([len(self.drawn[id(i)]) for i in self.iters if not self.final[id(i)]])
            except ValueError:
                l = 0
            _log.debug("Map%s(func=%s) Loop: %d, Final:%s" % (("<" + self.name + ">") if self.name else "", self.func.__name__, l, self.final.values()))
            # Execute map function l times
            for i in range(l):
                try:
                    self.func(self.out_iter, self.kwargs, [self.final[id(i)] for i in self.iters],
                              *[None if self.final[id(i)] else self.drawn[id(i)].pop(0) for i in self.iters])
                except PauseIteration:
                    break
                except StopIteration:
                    self.final = {id(k): True for k in self.iters}
                except Exception as e:
                    _log.exception("Map function failed")
                    raise e
            # If no more elements to apply map on, then one final map execution to allow the map function to finalize
            if all(self.final.values()):
                try:
                    self.func(self.out_iter, self.kwargs, self.final.values(),
                              *([None]*len(self.iters)))
                except PauseIteration:
                    pass
                except StopIteration:
                    pass
                except Exception as e:
                    _log.exception("Map function failed")
                    raise e
            # If lazy break out of while True with the return value (or exception) otherwise break when no progress
            if not eager:
                _log.debug("Map%s(func=%s) TRY OUT %s" % (("<" + self.name + ">") if self.name else "", 
                                                         self.func.__name__, self.out_iter))
                try:
                    e = self.out_iter.next()
                except StopIteration:
                    _log.debug("Map%s(func=%s) GOT STOP" % (("<" + self.name + ">") if self.name else "", 
                                                         self.func.__name__))
                    self.during_next = False
                    raise StopIteration
                except PauseIteration:
                    _log.debug("Map%s(func=%s) GOT PAUSE" % (("<" + self.name + ">") if self.name else "", 
                                                         self.func.__name__))
                    self.during_next = False
                    raise PauseIteration
                _log.debug("Map%s(func=%s) GOT OUT %s" % (("<" + self.name + ">") if self.name else "", 
                                                         self.func.__name__, e))
                self.during_next = False
                return e
            if not active or all(self.final.values()):
                # Reach here only when eager, any exception will do to break loop in trig method
                self.during_next = False
                raise Exception()
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/utilities/dynops.py/Map._op/original