Example #1
0
        kinds=("allocation", ))

    def allocate_BogoMipsCapacity(self, value):
        if self.BogoMipsCapacity < value:
            return False
        self.BogoMipsCapacity -= value
        return True

    def deallocate_BogoMipsCapacity(self, value):
        self.BogoMipsCapacity += value

    def updateUsageState(self):
        # Update usage state
        if self.BogoMipsCapacity == 0:
            self._usageState = CF.Device.BUSY
        elif self.BogoMipsCapacity == 100000000:
            self._usageState = CF.Device.IDLE
        else:
            self._usageState = CF.Device.ACTIVE

    def execute(self, *args):
        if self.crashEnabled:
            os.kill(os.getpid(), signal.SIGKILL)
        return ExecutableDevice.execute(self, *args)


if __name__ == "__main__":
    logging.getLogger().setLevel(logging.DEBUG)
    logging.debug("Starting Device")
    start_device(CrashableExecutableDevice)
                                     mode="readonly",
                                     kinds=("allocation",))

  def allocate_BogoMipsCapacity (self, value):
    if self.BogoMipsCapacity < value:
      return False
    self.BogoMipsCapacity -= value
    return True

  def deallocate_BogoMipsCapacity (self, value):
    self.BogoMipsCapacity += value

  def updateUsageState (self):
    # Update usage state
    if self.BogoMipsCapacity == 0:
      self._usageState = CF.Device.BUSY
    elif self.BogoMipsCapacity == 100000000:
      self._usageState = CF.Device.IDLE
    else:
      self._usageState = CF.Device.ACTIVE

  def execute (self, *args):
    if self.crashEnabled:
      os.kill(os.getpid(), signal.SIGKILL)
    return ExecutableDevice.execute(self, *args)

if __name__ == "__main__":
    logging.getLogger().setLevel(logging.DEBUG)
    logging.debug("Starting Device")
    start_device(CrashableExecutableDevice)
Example #3
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see http://www.gnu.org/licenses/.
#

import signal

from ossie.cf import CF__POA
from ossie.resource import Resource, start_component
from ossie.utils.log4py import logging

class orphaned_child(CF__POA.Resource, Resource):
    def __init__(self, *args, **kwargs):
        Resource.__init__(self, *args, **kwargs)

        # Ignore normal termination signals to ensure that the process is
        # orphaned when the parent is terminated; start_component() normally
        # establishes handlers for these before creating the component instance
        signal.signal(signal.SIGINT, signal.SIG_IGN)
        signal.signal(signal.SIGTERM, signal.SIG_IGN)
        signal.signal(signal.SIGQUIT, signal.SIG_IGN)

    def releaseObject(self):
        # Overriden to prevent the normal automatic process exit that occurs
        # after releaseObject() in 1.9+
        pass

if __name__ == '__main__':
    logging.getLogger().setLevel(logging.WARN)
    logging.debug("Starting Component")
    start_component(orphaned_child)