Lua scripts locking

I am running an OnStableStudy lua script that creates some resources in other parts of my app. It POST’s to a server with the studies ID, and that server in turn tries to call the /studies/:id endpoint on Orthanc, to get the study data. I noticed this doesn’t work as Orthanc is locking when Lua scripts execute.

At first I thought it’s locking just this entity, but it’s actually locking the entire server. This seems extremely bad for performance, as if my other server is locked up, or overloaded etc, and the HTTP post in the Lua callback times out, it’s going to in turn cause Orthanc to lock up, degrading performance.

Is there anything I can do? Is this a SQLite related issue, or an Orthanc design issue?

Having a think about this more, I’ve realised I can work around this by pushing the concept of asynchronicity to within my application instead of relying on Orthanc to do it. Instead of doing what I needed to do in the POST endpoint itself, I’ll just create a delayed job in a queue somewhere, and process it asynchronously. That way the Lua callback can return quickly, minimizing impact.