# HG changeset patch # User Sebastien Jodogne # Date 1611250856 -3600 # Node ID 4038ae299b183fd228fb69fa04e1f32d35145074 # Parent 1248dadca1cdf6316e9be0da4413430073ba76b4 note about deadlocks in python plugins diff -r 1248dadca1cd -r 4038ae299b18 Sphinx/source/plugins/python.rst --- a/Sphinx/source/plugins/python.rst Thu Jan 21 08:42:20 2021 +0100 +++ b/Sphinx/source/plugins/python.rst Thu Jan 21 18:40:56 2021 +0100 @@ -279,18 +279,17 @@ .. warning:: - Your callback function will be called synchronously with - the core of Orthanc. This implies that deadlocks might emerge if - you call other core primitives of Orthanc in your callback (such - deadlocks are particular visible in the presence of other plugins - or Lua scripts). It is thus strongly advised to avoid any call to - the REST API of Orthanc in the callback. If you have to call other - primitives of Orthanc, you should make these calls in a separate - thread, passing the pending events to be processed through a - message queue. + In releases <= 3.0 of the Python plugin, deadlocks might emerge if + you call other core primitives of Orthanc (such as the REST API) in + your callback function. This issue has been `fixed in release 3.1 + `__. -Here is the template of a possible solution to avoid such deadlocks by -relying on the multithreading primitives of Python:: +As a **temporary workaround** against such deadlocks in releases <= +3.0, if you have to call other primitives of Orthanc, you should make +these calls in a separate thread, passing the pending events to be +processed through a message queue. Here is the template of a possible +solution to postpone such deadlocks as much as possible by relying on +the multithreading primitives of Python:: import orthanc import threading @@ -306,6 +305,12 @@ orthanc.RegisterOnChangeCallback(_OnChange) + +Beware that **this workaround is imperfect** and deadlocks have been +observed even if using it! Make sure to upgrade your plugin to solve +this issue for good. Note that this temporary workaround is not needed +in releases >= 3.1 of the plugin. + Accessing the content of a new instance