Do not raise exception if Activity is already stopped

If an Activity derived object is not started, silently return the
stop() function instead of raising an exception. This behaviour will
allow next processes to continue.

Change-Id: I005b11b1d1593574140c7d97eab97bf6edd73678
Closes-Bug: #1820297
This commit is contained in:
Rodolfo Alonso Hernandez 2019-04-01 13:49:24 +01:00
parent a3b706a774
commit 7cab51acdb
1 changed files with 3 additions and 4 deletions

View File

@ -307,12 +307,11 @@ class Activity(object):
"""Stops all child threads and activities and closes associated
sockets.
Re-initializes this activity to be able to start again.
Raise `ActivityException` if activity is not currently started.
Re-initializes this activity to be able to start again. If the activity
is not started (is already stopped), it will silently return.
"""
if not self.started:
raise ActivityException(desc='Cannot call stop when activity is '
'not started or has been stopped already.')
return
LOG.debug('Stopping activity %s.', self.name)
self._stop_timers()