Allow custom global executor for native callbacks
Summary: Makes `folly::AsyncioExecutor` an abstract class and adds new `folly::python::setExecutorForLoop()` (C++) and `folly.executor.set_executor_for_loop()` (Python) functions. These control what is returned by `folly::python::getExecutor()` and `folly.executor.get_executor()` and hence allow installing a custom system for handling native callbacks on the Python event loop. In this implementation we only allow the executor for a given Python event loop to be set _once_ before being explicitly cleared. An alternative which was discussed was returning the previous executor when setting a new one, allowing the caller to stack them. My rationale for not doing this is I think this makes it too easy to accidentally "lose" callbacks registered with an existing executor. Reviewed By: vladima, pranavtbhat Differential Revision: D32486564 fbshipit-source-id: 4c9ad4e5f2b7b89f1edafdb4eddd9ccacb23635f
Showing
Please register or sign in to comment