[Solved] Message Sequence in Messenger System

Hello dear All,

I’m trying to understand the workload of the messenger system.
From what i understood , at a step “N” , it will process all messages raised before giving back the hand to the engine for processing step “N+1”.

However it is not clear for me what happens in following case:

At Step N,Event A is received by ObjectB method that do some treatment whose result is sending of EventB.

Will EventB be considered for processing in this step or during the next Step of the Engine?

There are two answers, depending on whether you are talking about Python code or C++ code.

Whenever Python code throws a message, via messenger.send(), the handlers for that message are called immediately, before messenger.send() returns. So the answer to your question is that EventB will be processed immediately.

Whenever C++ code throws a message, via throw_event(), the Python handlers on this message are not called immediately, but rather the event is queued up for delivery to Python later.

I suspect, however, that you are primarily concerned with the first case.


You are right, i’m willing to deal only with python :slight_smile:.
So it means that i can enter an infinite step if my events start other events that start other events…
So the new Step of the Engine (rendering,…) would never be called again…

Damm i need to design a simple event queuing system, like a mailbox then…

You could also us taskMgr.doMethodLater with messenger.send() to send it slightly delayed, so the next step of the system can go, then the message would be sent.