Why ChangeType.STABLE_STUDY excuted after ChangeType.NEW_INSTANCE?

Hi.

Here is my python plugin:

def OnChange(changeType, level, resource):
    if changeType == orthanc.ChangeType.NEW_INSTANCE: 
       _send_images_peer()

    if changeType == orthanc.ChangeType.STABLE_STUDY:
        _create_db_row()

orthanc.RegisterOnChangeCallback(OnChange)

StableAge in orthanc.conf is 60 seconds.
I uploaded a study with many instances.
All instances upload takes 10 seconds.
So i expected STABLE_STUDY to executed after 70 seconds, right?
But it executes after 30 minutes, because NEW_INSTANCE calls _send_images_peer, which sends instances slowly (it is ok, we have slow internet speed).
Can i force STABLE_STUDY to be executed when all instances are uploaded and ignore NEW_INSTANCE execution?

Hi,

Changes are queued in the order they are created and then, sent to the OnChange handler one by one. So there is no way an event can pass other events in the queue.

You’ll have to change your logic to make your event handler much faster which is a good practice anyway. E.g, you could send images to peer asynchronously.

HTH,

Alain

1 Like