from gevent import monkey
monkey.patch_all()
をapp.py (flask run
などで使用しているファイル) の先頭に追加して解決。
Make the standard library cooperative.
The primary purpose of this module is to carefully patch, in place, portions of the standard library with gevent-friendly functions that behave in the same way as the original (at least as closely as possible).
The primary interface to this is the patch_all() function, which performs all the available patches. It accepts arguments to limit the patching to certain modules, but most programs should use the default values as they receive the most wide-spread testing, and some monkey patches have dependencies on others.
Patching should be done as early as possible in the lifecycle of the program. For example, the main module (the one that tests against
__main__
or is otherwise the first imported) should begin with this code, ideally before any other imports: