PythonEventHandler problem

Hi, Orekit forum.
I think there’s a problem with EventHandler.
I compile using Python 3.7 with Pycharm, orekit version is 11.2.

Occurred error:

  File "C:\", line 84, in setup_timesampler
orekit.InvalidArgsError: (<class 'cb.TimeSampler'>, 'withHandler', <TimingEvent: {-76,733.9124456846; -64,040.5502612592; 3,273.3168213818}>)
Error: Not freed memory blocks: 8, total unfreed memory 0.010223 MB

Process finished with exit code 1

The relevant codes are as(timesampler and timingevent(PythonEventHandler)):

from import PythonEventHandler


class CelestialBody():

        self.event_handler = TimingEvent().of_(TimeSampler)
        self.time_sampler = None

        self.date_history = self.event_handler.date_history
        self.pos_history = self.event_handler.pos_history
        self.vel_history = self.event_handler.vel_history
        self.rot_history = self.event_handler.rot_history

    def setup_timesampler(self, start, end, steps, mode=1, factor=2):
        """Create and attach TimeSampler to propagator."""
        self.time_sampler = TimeSampler(start, end, steps, mode, factor).withHandler(

class TimingEvent(PythonEventHandler):
    """TimingEvent handler."""

    def __init__(self):
        """Initialise a TimingEvent handler."""
        self.date_history = []
        self.pos_history = []
        self.vel_history = []
        self.rot_history = [] = 0
        super(PythonEventHandler, self).__init__()

    def init(self, initialstate, target):

    def eventOccurred(self, s, T, increasing):
        """Handle occured event.""" += 1
        if % 1 == 0:
            logger.debug(f"{s.getDate()} : event {}")


        return Action.CONTINUE

    def resetState(self, detector, oldState):
        """Reset TimingEvent handler to given state."""
        return oldState

If anyone knows about EventHandlers, please help.
I can provide you with more code if necessary.
Many thanks.


Hi Sky,

There are some examples of EventHandler in Python in the test suites, if you haven’t seen them please have a look at them, that may give you some examples. orekit_python_artifacts/test at version-11.3 · petrushy/orekit_python_artifacts · GitHub

It seems to fail on the TimeSampler initialization, this is your own class I think?