We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Blacklist common virtualenv folders by default
We should blacklist the folders below from being watched by Streamlit. This would fix the issue where some people hit the inotify watch limit when running Streamlit from a weird working directory.

* */.virtualenv
* */.venv
* */anaconda3
* */anaconda2
* */miniconda3
* */miniconda2
* Actually let's blacklist every hidden folder: `.*`


See also the config option `server.folderWatchBlacklist`. For this fix, you can probably use the same mechanism this config option uses.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/streamlit/watcher/LocalSourcesWatcher.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright 2018-2019 Streamlit Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import os
17 import sys
18 import collections
19 
20 try:
21     # Python 2
22     import imp as importlib
23 except ImportError:
24     # Python 3
25     import importlib
26 
27 from streamlit import config
28 from streamlit import util
29 
30 from streamlit.logger import get_logger
31 LOGGER = get_logger(__name__)
32 
33 try:
34     # If the watchdog module is installed.
35     from streamlit.watcher.EventBasedFileWatcher import (
36         EventBasedFileWatcher as FileWatcher,
37     )
38 except ImportError:
39     # Fallback that doesn't use watchdog.
40     from streamlit.watcher.PollingFileWatcher import PollingFileWatcher as FileWatcher
41 
42     if not config.get_option('global.disableWatchdogWarning'):
43         msg = '\n  $ xcode-select --install' if util.is_darwin() else ''
44 
45         LOGGER.warning("""
46   For better performance, install the Watchdog module:
47   %s
48   $ pip install watchdog
49 
50         """ % msg)
51 
52 
53 WatchedModule = collections.namedtuple("WatchedModule", ["watcher", "module_name"])
54 
55 
56 class LocalSourcesWatcher(object):
57     def __init__(self, report, on_file_changed):
58         self._report = report
59         self._on_file_changed = on_file_changed
60         self._is_closed = False
61 
62         self._folder_blacklist = config.get_option("server.folderWatchBlacklist")
63 
64         # A dict of filepath -> WatchedModule.
65         self._watched_modules = {}
66 
67         self._register_watcher(
68             self._report.script_path,
69             module_name=None,  # Only the root script has None here.
70         )
71 
72     def on_file_changed(self, filepath):
73         if filepath not in self._watched_modules:
74             LOGGER.error("Received event for non-watched file", filepath)
75             return
76 
77         wm = self._watched_modules[filepath]
78 
79         if wm.module_name is not None and wm.module_name in sys.modules:
80             del sys.modules[wm.module_name]
81 
82         self._on_file_changed()
83 
84     def close(self):
85         for wm in self._watched_modules.values():
86             wm.watcher.close()
87         self._watched_modules = {}
88         self._is_closed = True
89 
90     def _register_watcher(self, filepath, module_name):
91         wm = WatchedModule(
92             watcher=FileWatcher(filepath, self.on_file_changed), module_name=module_name
93         )
94         self._watched_modules[filepath] = wm
95 
96     def _deregister_watcher(self, filepath):
97         if filepath not in self._watched_modules:
98             return
99 
100         if filepath == self._report.script_path:
101             return
102 
103         wm = self._watched_modules[filepath]
104         wm.watcher.close()
105         del self._watched_modules[filepath]
106 
107     def update_watched_modules(self):
108         if self._is_closed:
109             return
110 
111         local_filepaths = []
112 
113         # Clone modules dict here because we may alter the original dict inside
114         # the loop.
115         modules = dict(sys.modules)
116 
117         for name, module in modules.items():
118             try:
119                 spec = getattr(module, "__spec__", None)
120 
121                 if spec is None:
122                     filepath = getattr(module, "__file__", None)
123                     if filepath is None:
124                         # Some modules have neither a spec nor a file. But we
125                         # can ignore those since they're not the user-created
126                         # modules we want to watch anyway.
127                         continue
128                 else:
129                     filepath = spec.origin
130 
131                 if filepath is None:
132                     # Built-in modules (and other stuff) don't have origins.
133                     continue
134 
135                 filepath = os.path.abspath(filepath)
136 
137                 if not os.path.isfile(filepath):
138                     # There are some modules that have a .origin, but don't
139                     # point to real files. For example, there's a module where
140                     # .origin is 'built-in'.
141                     continue
142 
143                 folder_is_blacklisted = any(
144                     _file_is_in_folder(filepath, blacklisted_folder)
145                     for blacklisted_folder in self._folder_blacklist
146                 )
147 
148                 if folder_is_blacklisted:
149                     continue
150 
151                 file_is_new = filepath not in self._watched_modules
152                 file_is_local = _file_is_in_folder(filepath, self._report.script_folder)
153 
154                 local_filepaths.append(filepath)
155 
156                 if file_is_local and file_is_new:
157                     self._register_watcher(filepath, name)
158 
159             except Exception:
160                 # In case there's a problem introspecting some specific module,
161                 # let's not stop the entire loop from running.  For example,
162                 # the __spec__ field in some modules (like IPython) is actually
163                 # a dynamic property, which can crash if the underlying
164                 # module's code has a bug (as discovered by one of our users).
165                 continue
166 
167         # Clone dict here because we may alter the original dict inside the
168         # loop.
169         watched_modules = dict(self._watched_modules)
170 
171         # Remove no-longer-depended-on files from self._watched_modules
172         # Will this ever happen?
173         for filepath in watched_modules:
174             if filepath not in local_filepaths:
175                 self._deregister_watcher(filepath)
176 
177 
178 def _file_is_in_folder(filepath, folderpath):
179     # Assumes filepath is an absolute path, as a teeny tiny optimization.
180     folderpath = os.path.abspath(folderpath) + "/"
181     return filepath.startswith(folderpath)
182
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lib/streamlit/watcher/LocalSourcesWatcher.py b/lib/streamlit/watcher/LocalSourcesWatcher.py
--- a/lib/streamlit/watcher/LocalSourcesWatcher.py
+++ b/lib/streamlit/watcher/LocalSourcesWatcher.py
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import fnmatch
 import os
 import sys
 import collections
@@ -28,6 +29,7 @@
 from streamlit import util
 
 from streamlit.logger import get_logger
+
 LOGGER = get_logger(__name__)
 
 try:
@@ -39,15 +41,24 @@
     # Fallback that doesn't use watchdog.
     from streamlit.watcher.PollingFileWatcher import PollingFileWatcher as FileWatcher
 
-    if not config.get_option('global.disableWatchdogWarning'):
-        msg = '\n  $ xcode-select --install' if util.is_darwin() else ''
+    if not config.get_option("global.disableWatchdogWarning"):
+        msg = "\n  $ xcode-select --install" if util.is_darwin() else ""
 
-        LOGGER.warning("""
+        LOGGER.warning(
+            """
   For better performance, install the Watchdog module:
   %s
   $ pip install watchdog
 
-        """ % msg)
+        """
+            % msg
+        )
+
+
+# Streamlit never watches files in the folders below.
+DEFAULT_FOLDER_BLACKLIST = [
+    "**/.*", "**/anaconda2", "**/anaconda3", "**/miniconda2", "**/miniconda3"
+]
 
 
 WatchedModule = collections.namedtuple("WatchedModule", ["watcher", "module_name"])
@@ -61,6 +72,9 @@
 
         self._folder_blacklist = config.get_option("server.folderWatchBlacklist")
 
+        # Blacklist some additional folders, using glob syntax.
+        self._folder_blacklist.extend(DEFAULT_FOLDER_BLACKLIST)
+
         # A dict of filepath -> WatchedModule.
         self._watched_modules = {}
 
@@ -140,12 +154,12 @@
                     # .origin is 'built-in'.
                     continue
 
-                folder_is_blacklisted = any(
+                is_in_blacklisted_folder = any(
                     _file_is_in_folder(filepath, blacklisted_folder)
                     for blacklisted_folder in self._folder_blacklist
                 )
 
-                if folder_is_blacklisted:
+                if is_in_blacklisted_folder:
                     continue
 
                 file_is_new = filepath not in self._watched_modules
@@ -175,7 +189,10 @@
                 self._deregister_watcher(filepath)
 
 
-def _file_is_in_folder(filepath, folderpath):
-    # Assumes filepath is an absolute path, as a teeny tiny optimization.
-    folderpath = os.path.abspath(folderpath) + "/"
-    return filepath.startswith(folderpath)
+def _file_is_in_folder(filepath, folderpath_glob):
+    # Strip trailing slash if it exists
+    if folderpath_glob.endswith("/"):
+        folderpath_glob = folderpath_glob[:-1]
+
+    file_dir = os.path.dirname(filepath)
+    return fnmatch.fnmatch(file_dir, folderpath_glob)

{"golden_diff": "diff --git a/lib/streamlit/watcher/LocalSourcesWatcher.py b/lib/streamlit/watcher/LocalSourcesWatcher.py\n--- a/lib/streamlit/watcher/LocalSourcesWatcher.py\n+++ b/lib/streamlit/watcher/LocalSourcesWatcher.py\n@@ -13,6 +13,7 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n+import fnmatch\n import os\n import sys\n import collections\n@@ -28,6 +29,7 @@\n from streamlit import util\n \n from streamlit.logger import get_logger\n+\n LOGGER = get_logger(__name__)\n \n try:\n@@ -39,15 +41,24 @@\n     # Fallback that doesn't use watchdog.\n     from streamlit.watcher.PollingFileWatcher import PollingFileWatcher as FileWatcher\n \n-    if not config.get_option('global.disableWatchdogWarning'):\n-        msg = '\\n  $ xcode-select --install' if util.is_darwin() else ''\n+    if not config.get_option(\"global.disableWatchdogWarning\"):\n+        msg = \"\\n  $ xcode-select --install\" if util.is_darwin() else \"\"\n \n-        LOGGER.warning(\"\"\"\n+        LOGGER.warning(\n+            \"\"\"\n   For better performance, install the Watchdog module:\n   %s\n   $ pip install watchdog\n \n-        \"\"\" % msg)\n+        \"\"\"\n+            % msg\n+        )\n+\n+\n+# Streamlit never watches files in the folders below.\n+DEFAULT_FOLDER_BLACKLIST = [\n+    \"**/.*\", \"**/anaconda2\", \"**/anaconda3\", \"**/miniconda2\", \"**/miniconda3\"\n+]\n \n \n WatchedModule = collections.namedtuple(\"WatchedModule\", [\"watcher\", \"module_name\"])\n@@ -61,6 +72,9 @@\n \n         self._folder_blacklist = config.get_option(\"server.folderWatchBlacklist\")\n \n+        # Blacklist some additional folders, using glob syntax.\n+        self._folder_blacklist.extend(DEFAULT_FOLDER_BLACKLIST)\n+\n         # A dict of filepath -> WatchedModule.\n         self._watched_modules = {}\n \n@@ -140,12 +154,12 @@\n                     # .origin is 'built-in'.\n                     continue\n \n-                folder_is_blacklisted = any(\n+                is_in_blacklisted_folder = any(\n                     _file_is_in_folder(filepath, blacklisted_folder)\n                     for blacklisted_folder in self._folder_blacklist\n                 )\n \n-                if folder_is_blacklisted:\n+                if is_in_blacklisted_folder:\n                     continue\n \n                 file_is_new = filepath not in self._watched_modules\n@@ -175,7 +189,10 @@\n                 self._deregister_watcher(filepath)\n \n \n-def _file_is_in_folder(filepath, folderpath):\n-    # Assumes filepath is an absolute path, as a teeny tiny optimization.\n-    folderpath = os.path.abspath(folderpath) + \"/\"\n-    return filepath.startswith(folderpath)\n+def _file_is_in_folder(filepath, folderpath_glob):\n+    # Strip trailing slash if it exists\n+    if folderpath_glob.endswith(\"/\"):\n+        folderpath_glob = folderpath_glob[:-1]\n+\n+    file_dir = os.path.dirname(filepath)\n+    return fnmatch.fnmatch(file_dir, folderpath_glob)\n", "issue": "Blacklist common virtualenv folders by default\nWe should blacklist the folders below from being watched by Streamlit. This would fix the issue where some people hit the inotify watch limit when running Streamlit from a weird working directory.\r\n\r\n* */.virtualenv\r\n* */.venv\r\n* */anaconda3\r\n* */anaconda2\r\n* */miniconda3\r\n* */miniconda2\r\n* Actually let's blacklist every hidden folder: `.*`\r\n\r\n\r\nSee also the config option `server.folderWatchBlacklist`. For this fix, you can probably use the same mechanism this config option uses.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2018-2019 Streamlit Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport sys\nimport collections\n\ntry:\n    # Python 2\n    import imp as importlib\nexcept ImportError:\n    # Python 3\n    import importlib\n\nfrom streamlit import config\nfrom streamlit import util\n\nfrom streamlit.logger import get_logger\nLOGGER = get_logger(__name__)\n\ntry:\n    # If the watchdog module is installed.\n    from streamlit.watcher.EventBasedFileWatcher import (\n        EventBasedFileWatcher as FileWatcher,\n    )\nexcept ImportError:\n    # Fallback that doesn't use watchdog.\n    from streamlit.watcher.PollingFileWatcher import PollingFileWatcher as FileWatcher\n\n    if not config.get_option('global.disableWatchdogWarning'):\n        msg = '\\n  $ xcode-select --install' if util.is_darwin() else ''\n\n        LOGGER.warning(\"\"\"\n  For better performance, install the Watchdog module:\n  %s\n  $ pip install watchdog\n\n        \"\"\" % msg)\n\n\nWatchedModule = collections.namedtuple(\"WatchedModule\", [\"watcher\", \"module_name\"])\n\n\nclass LocalSourcesWatcher(object):\n    def __init__(self, report, on_file_changed):\n        self._report = report\n        self._on_file_changed = on_file_changed\n        self._is_closed = False\n\n        self._folder_blacklist = config.get_option(\"server.folderWatchBlacklist\")\n\n        # A dict of filepath -> WatchedModule.\n        self._watched_modules = {}\n\n        self._register_watcher(\n            self._report.script_path,\n            module_name=None,  # Only the root script has None here.\n        )\n\n    def on_file_changed(self, filepath):\n        if filepath not in self._watched_modules:\n            LOGGER.error(\"Received event for non-watched file\", filepath)\n            return\n\n        wm = self._watched_modules[filepath]\n\n        if wm.module_name is not None and wm.module_name in sys.modules:\n            del sys.modules[wm.module_name]\n\n        self._on_file_changed()\n\n    def close(self):\n        for wm in self._watched_modules.values():\n            wm.watcher.close()\n        self._watched_modules = {}\n        self._is_closed = True\n\n    def _register_watcher(self, filepath, module_name):\n        wm = WatchedModule(\n            watcher=FileWatcher(filepath, self.on_file_changed), module_name=module_name\n        )\n        self._watched_modules[filepath] = wm\n\n    def _deregister_watcher(self, filepath):\n        if filepath not in self._watched_modules:\n            return\n\n        if filepath == self._report.script_path:\n            return\n\n        wm = self._watched_modules[filepath]\n        wm.watcher.close()\n        del self._watched_modules[filepath]\n\n    def update_watched_modules(self):\n        if self._is_closed:\n            return\n\n        local_filepaths = []\n\n        # Clone modules dict here because we may alter the original dict inside\n        # the loop.\n        modules = dict(sys.modules)\n\n        for name, module in modules.items():\n            try:\n                spec = getattr(module, \"__spec__\", None)\n\n                if spec is None:\n                    filepath = getattr(module, \"__file__\", None)\n                    if filepath is None:\n                        # Some modules have neither a spec nor a file. But we\n                        # can ignore those since they're not the user-created\n                        # modules we want to watch anyway.\n                        continue\n                else:\n                    filepath = spec.origin\n\n                if filepath is None:\n                    # Built-in modules (and other stuff) don't have origins.\n                    continue\n\n                filepath = os.path.abspath(filepath)\n\n                if not os.path.isfile(filepath):\n                    # There are some modules that have a .origin, but don't\n                    # point to real files. For example, there's a module where\n                    # .origin is 'built-in'.\n                    continue\n\n                folder_is_blacklisted = any(\n                    _file_is_in_folder(filepath, blacklisted_folder)\n                    for blacklisted_folder in self._folder_blacklist\n                )\n\n                if folder_is_blacklisted:\n                    continue\n\n                file_is_new = filepath not in self._watched_modules\n                file_is_local = _file_is_in_folder(filepath, self._report.script_folder)\n\n                local_filepaths.append(filepath)\n\n                if file_is_local and file_is_new:\n                    self._register_watcher(filepath, name)\n\n            except Exception:\n                # In case there's a problem introspecting some specific module,\n                # let's not stop the entire loop from running.  For example,\n                # the __spec__ field in some modules (like IPython) is actually\n                # a dynamic property, which can crash if the underlying\n                # module's code has a bug (as discovered by one of our users).\n                continue\n\n        # Clone dict here because we may alter the original dict inside the\n        # loop.\n        watched_modules = dict(self._watched_modules)\n\n        # Remove no-longer-depended-on files from self._watched_modules\n        # Will this ever happen?\n        for filepath in watched_modules:\n            if filepath not in local_filepaths:\n                self._deregister_watcher(filepath)\n\n\ndef _file_is_in_folder(filepath, folderpath):\n    # Assumes filepath is an absolute path, as a teeny tiny optimization.\n    folderpath = os.path.abspath(folderpath) + \"/\"\n    return filepath.startswith(folderpath)\n", "path": "lib/streamlit/watcher/LocalSourcesWatcher.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2018-2019 Streamlit Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport fnmatch\nimport os\nimport sys\nimport collections\n\ntry:\n    # Python 2\n    import imp as importlib\nexcept ImportError:\n    # Python 3\n    import importlib\n\nfrom streamlit import config\nfrom streamlit import util\n\nfrom streamlit.logger import get_logger\n\nLOGGER = get_logger(__name__)\n\ntry:\n    # If the watchdog module is installed.\n    from streamlit.watcher.EventBasedFileWatcher import (\n        EventBasedFileWatcher as FileWatcher,\n    )\nexcept ImportError:\n    # Fallback that doesn't use watchdog.\n    from streamlit.watcher.PollingFileWatcher import PollingFileWatcher as FileWatcher\n\n    if not config.get_option(\"global.disableWatchdogWarning\"):\n        msg = \"\\n  $ xcode-select --install\" if util.is_darwin() else \"\"\n\n        LOGGER.warning(\n            \"\"\"\n  For better performance, install the Watchdog module:\n  %s\n  $ pip install watchdog\n\n        \"\"\"\n            % msg\n        )\n\n\n# Streamlit never watches files in the folders below.\nDEFAULT_FOLDER_BLACKLIST = [\n    \"**/.*\", \"**/anaconda2\", \"**/anaconda3\", \"**/miniconda2\", \"**/miniconda3\"\n]\n\n\nWatchedModule = collections.namedtuple(\"WatchedModule\", [\"watcher\", \"module_name\"])\n\n\nclass LocalSourcesWatcher(object):\n    def __init__(self, report, on_file_changed):\n        self._report = report\n        self._on_file_changed = on_file_changed\n        self._is_closed = False\n\n        self._folder_blacklist = config.get_option(\"server.folderWatchBlacklist\")\n\n        # Blacklist some additional folders, using glob syntax.\n        self._folder_blacklist.extend(DEFAULT_FOLDER_BLACKLIST)\n\n        # A dict of filepath -> WatchedModule.\n        self._watched_modules = {}\n\n        self._register_watcher(\n            self._report.script_path,\n            module_name=None,  # Only the root script has None here.\n        )\n\n    def on_file_changed(self, filepath):\n        if filepath not in self._watched_modules:\n            LOGGER.error(\"Received event for non-watched file\", filepath)\n            return\n\n        wm = self._watched_modules[filepath]\n\n        if wm.module_name is not None and wm.module_name in sys.modules:\n            del sys.modules[wm.module_name]\n\n        self._on_file_changed()\n\n    def close(self):\n        for wm in self._watched_modules.values():\n            wm.watcher.close()\n        self._watched_modules = {}\n        self._is_closed = True\n\n    def _register_watcher(self, filepath, module_name):\n        wm = WatchedModule(\n            watcher=FileWatcher(filepath, self.on_file_changed), module_name=module_name\n        )\n        self._watched_modules[filepath] = wm\n\n    def _deregister_watcher(self, filepath):\n        if filepath not in self._watched_modules:\n            return\n\n        if filepath == self._report.script_path:\n            return\n\n        wm = self._watched_modules[filepath]\n        wm.watcher.close()\n        del self._watched_modules[filepath]\n\n    def update_watched_modules(self):\n        if self._is_closed:\n            return\n\n        local_filepaths = []\n\n        # Clone modules dict here because we may alter the original dict inside\n        # the loop.\n        modules = dict(sys.modules)\n\n        for name, module in modules.items():\n            try:\n                spec = getattr(module, \"__spec__\", None)\n\n                if spec is None:\n                    filepath = getattr(module, \"__file__\", None)\n                    if filepath is None:\n                        # Some modules have neither a spec nor a file. But we\n                        # can ignore those since they're not the user-created\n                        # modules we want to watch anyway.\n                        continue\n                else:\n                    filepath = spec.origin\n\n                if filepath is None:\n                    # Built-in modules (and other stuff) don't have origins.\n                    continue\n\n                filepath = os.path.abspath(filepath)\n\n                if not os.path.isfile(filepath):\n                    # There are some modules that have a .origin, but don't\n                    # point to real files. For example, there's a module where\n                    # .origin is 'built-in'.\n                    continue\n\n                is_in_blacklisted_folder = any(\n                    _file_is_in_folder(filepath, blacklisted_folder)\n                    for blacklisted_folder in self._folder_blacklist\n                )\n\n                if is_in_blacklisted_folder:\n                    continue\n\n                file_is_new = filepath not in self._watched_modules\n                file_is_local = _file_is_in_folder(filepath, self._report.script_folder)\n\n                local_filepaths.append(filepath)\n\n                if file_is_local and file_is_new:\n                    self._register_watcher(filepath, name)\n\n            except Exception:\n                # In case there's a problem introspecting some specific module,\n                # let's not stop the entire loop from running.  For example,\n                # the __spec__ field in some modules (like IPython) is actually\n                # a dynamic property, which can crash if the underlying\n                # module's code has a bug (as discovered by one of our users).\n                continue\n\n        # Clone dict here because we may alter the original dict inside the\n        # loop.\n        watched_modules = dict(self._watched_modules)\n\n        # Remove no-longer-depended-on files from self._watched_modules\n        # Will this ever happen?\n        for filepath in watched_modules:\n            if filepath not in local_filepaths:\n                self._deregister_watcher(filepath)\n\n\ndef _file_is_in_folder(filepath, folderpath_glob):\n    # Strip trailing slash if it exists\n    if folderpath_glob.endswith(\"/\"):\n        folderpath_glob = folderpath_glob[:-1]\n\n    file_dir = os.path.dirname(filepath)\n    return fnmatch.fnmatch(file_dir, folderpath_glob)\n", "path": "lib/streamlit/watcher/LocalSourcesWatcher.py"}]}