Nir Soffer has uploaded a new change for review. Change subject: pthreading: Monkeypatch threading module first ......................................................................
pthreading: Monkeypatch threading module first When using Python 2 we must monkey patch threading module before any other module is imported. Next version of pthreading will raise if monkey_patch() is called too late. Change-Id: I49d327d0fd7c78edef62ecd43999651a475fee4d Signed-off-by: Nir Soffer <[email protected]> --- M tests/testrunner.py M vdsm/vdsm 2 files changed, 17 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/28738/1 diff --git a/tests/testrunner.py b/tests/testrunner.py index ac0f90f..85da686 100644 --- a/tests/testrunner.py +++ b/tests/testrunner.py @@ -17,8 +17,16 @@ # # Refer to the README and COPYING files for full details of the license # -import logging + import sys + +# When using Python 2, we must monkey patch threading module before importing +# any other module. +if sys.version_info[0] == 2: + import pthreading + pthreading.monkey_patch() + +import logging import os import unittest from functools import wraps @@ -32,14 +40,6 @@ from nose import config from nose import core from nose import result - -# Monkey patch pthreading in necessary -if sys.version_info[0] == 2: - # as long as we work with Python 2, we need to monkey-patch threading - # module before it is ever used. - import pthreading - pthreading.monkey_patch() - from testValidation import SlowTestsPlugin, StressTestsPlugin diff --git a/vdsm/vdsm b/vdsm/vdsm index 8a3eabc..cbc16ff 100755 --- a/vdsm/vdsm +++ b/vdsm/vdsm @@ -8,8 +8,15 @@ # LICENSE_GPL_v2 which accompany this distribution. # -import os import sys + +# When using Python 2, we must monkey patch threading module before importing +# any other module. +if sys.version_info[0] == 2: + import pthreading + pthreading.monkey_patch() + +import os import getopt import signal import getpass @@ -33,11 +40,6 @@ import zombiereaper import dsaversion -if sys.version_info[0] == 2: - # as long as we work with Python 2, we need to monkey-patch threading - # module before it is ever used. - import pthreading - pthreading.monkey_patch() loggerConfFile = constants.P_VDSM_CONF + 'logger.conf' -- To view, visit http://gerrit.ovirt.org/28738 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49d327d0fd7c78edef62ecd43999651a475fee4d Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
