| 248 | |
| 249 | |
| 250 | class SynchroModuleLoader(importlib.abc.Loader): |
| 251 | def patch_spec(self, fullname): |
| 252 | parts = fullname.split(".") |
| 253 | if ("pymongo" in parts or "gridfs" in parts) and "asynchronous" not in parts: |
| 254 | return True |
| 255 | |
| 256 | return False |
| 257 | |
| 258 | def exec_module(self, module): |
| 259 | pass |
| 260 | |
| 261 | def create_module(self, spec): |
| 262 | if self.patch_spec(spec.name): |
| 263 | return synchro |
| 264 | |
| 265 | # Let regular module search continue. |
| 266 | return None |
| 267 | |
| 268 | |
| 269 | class SynchroPytestPlugin: |