compileOrc vs compileOrcAsync

Hello,

can someone help me deeply understand the differences between compileOrcAsync and compileOrc in ctcsound.py API?

For my livecoding system I feel that using compileOrc is the best way to send my scores to csound, but the time for csound to execute with compileOrc it’s completely unpredictable. Sometimes it’s immediately and sometimes it takes like 2 or 3 seconds. I really cannot figure out what’s the main raison.
If i use compileOrcAsync everything is immediately, but if i send a code where there’s a GEN and some instruments, sometimes the instruments that use this gen are execute before and the results is obviously an error.
Can someone help me better understand the csound API priorities?
Thank you,

when using a performanceThread, compileOrc will block at least for an entire block. using async will return immediately. In order to ensure that the compilation has taken effect you need to sync to the csound process. See the implementation of sync in csoundengine: https://github.com/gesellkammer/csoundengine/blob/626760ccf0c4a2309627fb17fd042f2236ce537e/csoundengine/engine.py#L1081C10-L1081C10

It is an involved process and there is definitely room for improvement at the API design level in this regard.