canvas-medical / canvas-plugins

1 stars 0 forks source link

Run Protocol compute method in a threadpool to avoid blocking the main event loop #51

Closed csande closed 4 months ago

csande commented 4 months ago

The compute method on Protocols runs in an async context, but authors of that method may not realize that. Given that, developers could very easily block the main thread by doing normal things like using the requests package to send HTTP requests.

This change makes user-defined code run in a thread from the default executor threadpool.

Note that this does not cause protocols to run in parallel — a future PR will address this after we get an idea for what if any limitations to set for parallel execution, for example max threads per event.