[RigoDaemon] make possible to interrupt the Application Management activity

This commit is contained in:
Fabio Erculiani
2012-04-05 17:09:41 +02:00
parent fac687326f
commit d845fce5a3
2 changed files with 38 additions and 4 deletions
+36 -4
View File
@@ -415,6 +415,12 @@ class RigoDaemonService(dbus.service.Object):
"""
return self._authorized
def set_authorized(self, val):
"""
Set a new authorization value.
"""
self._authorized = val
def __str__(self):
"""
Show item in human readable way
@@ -446,6 +452,12 @@ class RigoDaemonService(dbus.service.Object):
"""
return self._authorized
def set_authorized(self, val):
"""
Set a new authorization value.
"""
self._authorized = val
def __str__(self):
"""
Show item in human readable way
@@ -479,6 +491,8 @@ class RigoDaemonService(dbus.service.Object):
self._txs = ApplicationsTransaction()
# used by non-daemon thread to exit
self._stop_signal = False
# used by clients to interrupt an ongoing activity
self._interrupt_activity = False
# original standard output and error files
self._old_stdout = sys.stdout
@@ -736,7 +750,12 @@ class RigoDaemonService(dbus.service.Object):
"""
while True:
self._action_queue_waiter.acquire() # CANBLOCK
acquired = self._action_queue_waiter.acquire(False)
if not acquired:
# this means that the queue is empty, and
# we can turn off the activity interruption signal
self._interrupt_activity = False
self._action_queue_waiter.acquire() # CANBLOCK
if self._stop_signal:
write_output("_action_queue_worker_thread: bye bye!",
debug=True)
@@ -746,10 +765,14 @@ class RigoDaemonService(dbus.service.Object):
try:
item = self._action_queue.popleft()
except IndexError:
# mumble, no more items, this shouldn't have happened
# no more items
write_output("_action_queue_worker_thread: "
"no item popped!", debug=True)
continue
"empty pop", debug=True)
break
# change execution authorization
if self._interrupt_activity:
item.set_authorized(False)
write_output("_action_queue_worker_thread: "
"got: %s" % (item,), debug=True)
@@ -1768,6 +1791,15 @@ class RigoDaemonService(dbus.service.Object):
self._enqueue_action_busy_hold_sem.release()
raise
@dbus.service.method(BUS_NAME, in_signature='',
out_signature='')
def interrupt_activity(self):
"""
Interrupt any ongoing Activity
"""
write_output("interrupt_activity called", debug=True)
self._interrupt_activity = True
@dbus.service.method(BUS_NAME, in_signature='',
out_signature='i')
def activity(self):
@@ -25,6 +25,8 @@
<arg name="accepted" type="b" direction="out"/>
</method>
<method name="interrupt_activity"/>
<method name="action_queue_length">
<arg name="length" type="i" direction="out"/>
</method>