Module EDPluginExec
[hide private]
[frames] | no frames]

Source Code for Module EDPluginExec

 1  # coding: utf8 
 2  # 
 3  #    Project: The EDNA Kernel 
 4  #             http://www.edna-site.org 
 5  # 
 6  #    File: "$Id$" 
 7  # 
 8  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
 9  #                            Grenoble, France 
10  # 
11  #    Principal authors: Marie-Francoise Incardona (incardon@esrf.fr) 
12  #                       Olof Svensson (svensson@esrf.fr)  
13  #                       Jérôme Kieffer (jerome.kieffer@esrf.fr)  
14  # 
15  #    This program is free software: you can redistribute it and/or modify 
16  #    it under the terms of the GNU Lesser General Public License as published 
17  #    by the Free Software Foundation, either version 3 of the License, or 
18  #    (at your option) any later version. 
19  # 
20  #    This program is distributed in the hope that it will be useful, 
21  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
22  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
23  #    GNU Lesser General Public License for more details. 
24  # 
25  #    You should have received a copy of the GNU General Public License 
26  #    and the GNU Lesser General Public License  along with this program.   
27  #    If not, see <http://www.gnu.org/licenses/>. 
28  # 
29   
30  __authors__ = [ "Marie-Francoise Incardona", "Olof Svensson", "Jérôme Kieffer" ] 
31  __contact__ = "svensson@esrf.fr" 
32  __license__ = "LGPLv3+" 
33  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
34   
35   
36  from EDPlugin import EDPlugin 
37  from EDUtilsParallel import EDUtilsParallel 
38  from EDVerbose import EDVerbose 
39   
40   
41 -class EDPluginExec(EDPlugin):
42 """ 43 Super class for all plugins that execute something. 44 For now, does nothing. 45 """ 46 47
48 - def preProcess(self, _edObject=None):
49 """ 50 preProcess of the plugin: 51 Ensure a CPU resource is available for the processing by acquiring a semaphore 52 """ 53 EDVerbose.DEBUG("Acquire semaphore nbCPU by plugin %s, currently value: %s" % (self.getPluginName(), EDUtilsParallel.getSemaphoreValue())) 54 EDUtilsParallel.semaphoreNbThreadsAcquire() 55 EDPlugin.preProcess(self, _edObject)
56 57
58 - def finallyProcess(self, _edObject=None):
59 """ 60 after processing of the plugin: 61 Release a CPU resource by releasing the semaphore 62 """ 63 EDVerbose.DEBUG("Release semaphore nbCPU by plugin %s, currently value: %s" % (self.getPluginName(), EDUtilsParallel.getSemaphoreValue())) 64 EDUtilsParallel.semaphoreNbThreadsRelease() 65 EDPlugin.finallyProcess(self, _edObject)
66