Module: deluge
Branch: master
Commit: afa283cd2dec015dd0aa4280e55b5a6b12bb4dc2

Author: Andrew Resch <[email protected]>
Date:   Thu Apr  8 17:16:28 2010 -0700

Add an errback for when calling a component's start() fails and revert it back 
to a Stopped
state in this case

---

 deluge/component.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/deluge/component.py b/deluge/component.py
index 9ca34a1..a516fd9 100644
--- a/deluge/component.py
+++ b/deluge/component.py
@@ -108,11 +108,18 @@ class Component(object):
             self._component_start_timer()
             return True
 
+        def on_start_fail(result):
+            self._component_state = "Stopped"
+            self._component_starting_deferred = None
+            log.error(result)
+            return result
+
         if self._component_state == "Stopped":
             if hasattr(self, "start"):
                 self._component_state = "Starting"
                 d = maybeDeferred(self.start)
                 d.addCallback(on_start)
+                d.addErrback(on_start_fail)
                 self._component_starting_deferred = d
             else:
                 d = maybeDeferred(on_start, None)

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to