Functionality specific to the git fileserver backend
| 3827 | |
| 3828 | |
| 3829 | class GitFS(GitBase): |
| 3830 | """ |
| 3831 | Functionality specific to the git fileserver backend |
| 3832 | """ |
| 3833 | |
| 3834 | role = "gitfs" |
| 3835 | instance_map = weakref.WeakKeyDictionary() |
| 3836 | |
| 3837 | def __new__( |
| 3838 | cls, |
| 3839 | opts, |
| 3840 | remotes=None, |
| 3841 | per_remote_overrides=(), |
| 3842 | per_remote_only=PER_REMOTE_ONLY, |
| 3843 | git_providers=None, |
| 3844 | cache_root=None, |
| 3845 | init_remotes=True, |
| 3846 | ): |
| 3847 | """ |
| 3848 | If we are not initializing remotes (such as in cases where we just want |
| 3849 | to load the config so that we can run clear_cache), then just return a |
| 3850 | new __init__'ed object. Otherwise, check the instance map and re-use an |
| 3851 | instance if one exists for the current process. Weak references are |
| 3852 | used to ensure that we garbage collect instances for threads which have |
| 3853 | exited. |
| 3854 | """ |
| 3855 | # No need to get the ioloop reference if we're not initializing remotes |
| 3856 | io_loop = tornado.ioloop.IOLoop.current() if init_remotes else None |
| 3857 | if not init_remotes or io_loop not in cls.instance_map: |
| 3858 | # We only evaluate the second condition in this if statement if |
| 3859 | # we're initializing remotes, so we won't get here unless io_loop |
| 3860 | # is something other than None. |
| 3861 | obj = object.__new__(cls) |
| 3862 | super(GitFS, obj).__init__( |
| 3863 | opts, |
| 3864 | remotes if remotes is not None else [], |
| 3865 | per_remote_overrides=per_remote_overrides, |
| 3866 | per_remote_only=per_remote_only, |
| 3867 | git_providers=( |
| 3868 | git_providers if git_providers is not None else GIT_PROVIDERS |
| 3869 | ), |
| 3870 | cache_root=cache_root, |
| 3871 | init_remotes=init_remotes, |
| 3872 | ) |
| 3873 | if not init_remotes: |
| 3874 | log.debug("Created gitfs object with uninitialized remotes") |
| 3875 | else: |
| 3876 | log.debug("Created gitfs object for process %s", os.getpid()) |
| 3877 | # Add to the instance map so we can re-use later |
| 3878 | cls.instance_map[io_loop] = obj |
| 3879 | return obj |
| 3880 | log.debug("Re-using gitfs object for process %s", os.getpid()) |
| 3881 | return cls.instance_map[io_loop] |
| 3882 | |
| 3883 | # pylint: disable=super-init-not-called |
| 3884 | def __init__( |
| 3885 | self, |
| 3886 | opts, |