Flask (connexion) app not reloading monitored extra_files when building app as a python package

16 Views Asked by At

I have a python flask (using connexion) project that I need to reload if I change any of the files in the project. This project is built into a python module using setup.py, then run. I tried using extra_files parameter when running the project but this does not help. I could not tell if the extra_files cared about relative path, so I designed my code to provide full paths for all files. It still does not work.

I build the module with pip install -e ., then run it python -m thing.app.main But the module does not pick up on changes. I thought using links (using the -e editable) parameter would help but it does not.

I should also mention that I am running all this in my pyenv, so the paths that are run during run time maybe different as they are in the pyenv path. Is that a problem?

Is this expected? Is there a way I can use extra_files? or will I need to use a watchdog daemon to monitor file changes?

1

There are 1 best solutions below

0
Dave On

I figured it out.

  • I did not understand that Flask watchdog process already monitors all .py files in the project. I stopped trying to send it all .py files again with extra _files. I only sent my yaml/yml config files as extra_files.
  • Has nothing to do with it being a module or running locally.
  • Flask was actually reloading the files properly, however it was stopping after first reload. The main problem was the max_user_watches setting in inotify. I changed it with echo 524288 | sudo tee /proc/sys/fs/inotify/max_user_watches and now it works fine.