dchevell / flask-executor

Adds concurrent.futures support to Flask
MIT License
175 stars 26 forks source link

Using unpatched ThreadPoolExecutor when using gevent #50

Open barsa-net opened 1 year ago

barsa-net commented 1 year ago

I'm working on a project using gevent and I'd need to use gevent.threadpool.ThreadPoolExecutor since gevent patch the concurrent.futures.ThreadPoolExecutor class.

I'd be more than happy to open a pull request, but I'm not sure how would fit best the library.

There are some cavet though, gevent.threadpool.ThreadPoolExecutor uses a slightly modified Future object which doesn't have the following methods:

dchevell commented 1 year ago

Cool idea @barsa-net . I'm not against supporting this, though rather than explicitly hardcoding support for gevent I'd prefer to be able to just pass in one's own compatible class. Your idea of EXECUTOR_TYPE = 'custom' and EXECUTOR_POOL_CLASS = gevent.threadpool.ThreadPoolExecutor could certainly work.

I don't know what the implications would be of gevent's different Future objects. Perhaps you can test out your approach of allowing a custom executor pool class to be used, and see if you run into trouble. If it did work, then we could include gevent as a testing requirement and write some tests for that example of the feature.