From: Thierry Parmentelat Date: Wed, 4 Nov 2015 15:57:22 +0000 (+0100) Subject: util/guid.py merged into ec.py that is the only one using it X-Git-Tag: nepi-6.0.0-pypi~2 X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=commitdiff_plain;h=a3073450d0ef8f8becb9de04b64bf5d4fdbc2272 util/guid.py merged into ec.py that is the only one using it all-tests6 does all-tests2 and then all-tests3 --- diff --git a/all-tests b/all-tests index 404f82a7..5ede05d7 100755 --- a/all-tests +++ b/all-tests @@ -11,8 +11,13 @@ # cannot safely be run together; need to check the nepi exp_ids # used more closely +DIRNAME=$(dirname $0) COMMAND=$(basename $0) +if echo $COMMAND | grep -q 6; then + $DIRNAME/all-tests2; $DIRNAME/all-tests3; exit +fi + PYTHON=python version=2 echo $COMMAND | grep -q 3 && { PYTHON=python3; version=3; } @@ -21,6 +26,7 @@ hash=$(git log -n 1 | head -1 | sed -e 's,commit ,,' -e 's,\(........\).*,\1,') # compute output file name output="zz.$hash.py$version" +latest="zz.latest.py$version" # if there is any pending change, use another name is_pristine="" @@ -54,6 +60,9 @@ function all_tests () { # the current code for analyzing the output is very basic # this needs to be checked manually for some time +# create a 'latest' symlink +ln -f -s $output $latest + all_tests >& $output retcod=$? diff --git a/src/nepi/execution/ec.py b/src/nepi/execution/ec.py index c403d797..f282ac6f 100644 --- a/src/nepi/execution/ec.py +++ b/src/nepi/execution/ec.py @@ -18,7 +18,6 @@ from six import next -from nepi.util import guid from nepi.util.parallel import ParallelRun from nepi.util.timefuncs import tnow, tdiffsec, stabsformat, tsformat from nepi.execution.resource import ResourceFactory, ResourceAction, \ @@ -103,6 +102,23 @@ class ECState(object): RELEASED = 3 TERMINATED = 4 +# historical note: this class used to be in util/guid.py but is used only here +# FIXME: This class is not thread-safe. Should it be made thread-safe? +class GuidGenerator(object): + def __init__(self): + self._last_guid = 0 + + # historical note: this used to be called `next` + # which confused 2to3 - and me - while it has + # nothing to do at all with the iteration protocol + def generate(self, guid = None): + if guid == None: + guid = self._last_guid + 1 + + self._last_guid = self._last_guid if guid <= self._last_guid else guid + + return guid + class ExperimentController(object): """ .. note:: @@ -225,7 +241,7 @@ class ExperimentController(object): self._persist = persist # generator of globally unique ids - self._guid_generator = guid.GuidGenerator() + self._guid_generator = GuidGenerator() # Resource managers self._resources = dict() @@ -242,7 +258,7 @@ class ExperimentController(object): self._groups = dict() # generator of globally unique id for groups - self._group_id_generator = guid.GuidGenerator() + self._group_id_generator = GuidGenerator() # Flag to stop processing thread self._stop = False @@ -590,7 +606,7 @@ class ExperimentController(object): """ # Get next available guid # xxx_next_hiccup - guid = self._guid_generator.next(guid) + guid = self._guid_generator.generate(guid) # Instantiate RM rm = ResourceFactory.create(rtype, self, guid) @@ -989,7 +1005,7 @@ class ExperimentController(object): if not group: new_group = True # xxx_next_hiccup - group = self._group_id_generator.next() + group = self._group_id_generator.generate() if group not in self._groups: self._groups[group] = [] diff --git a/src/nepi/util/guid.py b/src/nepi/util/guid.py deleted file mode 100644 index 45852118..00000000 --- a/src/nepi/util/guid.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# NEPI, a framework to manage network experiments -# Copyright (C) 2013 INRIA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation; -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Author: Alina Quereilhac - -# FIXME: This class is not thread-safe. -# Should it be made thread-safe? -class GuidGenerator(object): - def __init__(self): - self._last_guid = 0 - - # xxx_next_hiccup - this is used as a plain function, and only in ec.py - def next(self, guid = None): - if guid == None: - guid = self._last_guid + 1 - - self._last_guid = self._last_guid if guid <= self._last_guid else guid - - return guid -