Zhou Zheng Sheng has uploaded a new change for review. Change subject: remoteFileHandler: drop the conditional protection of import ......................................................................
remoteFileHandler: drop the conditional protection of import When new child process of remoteFileHandler is started in unit test, there is no vdsm package installed, so we can not import modules under vdsm. There is an "if __name__ != 'main'" to conditionally not import modules from vdsm package in the child process. After commit d8778ad, which is reviewed at http://gerrit.ovirt.org/9217 , '../' is added to PYTHONPATH of the child process in unit test. The working dir of the child is ./tests, so "from vdsm import X" will get the module at ./tests/../vdsm/X.py . It can safely import modules under the vdsm package now. There is no need to protect the import statements. This patch removes the "if" statement. Change-Id: Ia6bb8e614db7db4a9e56ac59850bef2568468cf9 Signed-off-by: Zhou Zheng Sheng <[email protected]> --- M vdsm/storage/remoteFileHandler.py 1 file changed, 3 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/12872/1 diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py index f40518a..e2405ff 100644 --- a/vdsm/storage/remoteFileHandler.py +++ b/vdsm/storage/remoteFileHandler.py @@ -34,18 +34,14 @@ import misc import fileUtils import zombieReaper +from vdsm import constants +from vdsm.betterPopen import BetterPopen # Crabs are known for their remote process calls LENGTH_STRUCT_FMT = "Q" LENGTH_STRUCT_LENGTH = calcsize(LENGTH_STRUCT_FMT) -if __name__ != "__main__": - # If you don't have the vdsm package installed this will fail. Luckily we - # don't need anything when the child spawns. Plus anything you don't have - # to import is less memory taken by each helper. - from vdsm.betterPopen import BetterPopen - from vdsm import constants -else: +if __name__ == "__main__": # We add the parent directory so that imports that import the storage # package would work even though CWD is inside the storage package. sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), "../")) -- To view, visit http://gerrit.ovirt.org/12872 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia6bb8e614db7db4a9e56ac59850bef2568468cf9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Zhou Zheng Sheng <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
