OSError:[Errno 28]达到inotify监视限制

Jag*_*aut 6 python heroku heroku-api streamlit

我正在使用 Streamlit 制作一个基于 python 的 Web 应用程序。在Heroku中部署后,构建成功,但出现应用程序错误。我不知道源代码中的哪个位置生成了此错误。请帮我!错误 :

2022-07-18T18:55:37.985429+00:00 app[web.1]:     Inotify._raise_error()
2022-07-18T18:55:37.985439+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/watchdog/observers/inotify_c.py", line 398, in _raise_error
2022-07-18T18:55:37.985636+00:00 app[web.1]:     raise OSError(errno.ENOSPC, "inotify watch limit reached")
2022-07-18T18:55:37.985677+00:00 app[web.1]: OSError: [Errno 28] inotify watch limit reached
2022-07-18T18:55:38.387667+00:00 heroku[web.1]: Process exited with status 1
2022-07-18T18:55:38.510041+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-18T18:55:48.000000+00:00 app[api]: Build succeeded
2022-07-18T18:57:33.589417+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=invezto.herokuapp.com request_id=bc8f4556-852e-4dad-8b67-71e49ffaaf23 fwd="49.37.45.19" dyno= connect= service= status=503 bytes= protocol=https
2022-07-18T18:57:33.917128+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=invezto.herokuapp.com request_id=46e2e615-17dc-42f6-a86d-4dfc5fd5ecfc fwd="49.37.45.19" dyno= connect= service= status=503 bytes= protocol=https ``` 

 
Run Code Online (Sandbox Code Playgroud)

小智 14

--server.fileWatcherType none在命令行添加选项帮助我解决了类似的问题。完整的示例如下所示:

streamlit run app.py --server.fileWatcherType none
Run Code Online (Sandbox Code Playgroud)

更多解决方案在这里


Her*_*ert 8

Streamlit 递归地监视应用程序脚本的父文件夹中的更改,例如app.py [source]

这个想法是,如果源文件更新,应用程序将“重新运行”,以方便应用程序开发。但是,如果此文件夹包含太多子文件夹和子文件,显然watchdog会达到限制并引发错误。如果您直接从包含大量配置文件等的主目录运行,那么很容易发生这种情况。或者当您从包含大量文件的 git 存储库运行时.git (只是推测)。

您可以通过将app.py脚本放置在仅包含您在开发过程中编辑的依赖项的(子)文件夹中来解决此问题,或者--server.fileWatcherType none接受手动重新启动的麻烦。

streamlit run app.py --server.fileWatcherType none
Run Code Online (Sandbox Code Playgroud)

(根据@swwt的建议)