[Twisted-Python] returning value after addCallback

Ladislav Andel ladaan at iptel.org
Thu Aug 9 08:42:50 EDT 2007

you could tell me that I should stop programming since I don't know 
properly OOP but
I quite need to sort out this problem.
Here is another piece of code I have problem with.
Please be patient with me.

Where is mistake in my code. It is not returning any reasonable result.

Thank you for help.

-------------------------------------- code 

from twisted.internet import reactor, defer, threads

from siptest import siptest_f

test_opts = 
domain = ['sip.1und1.de', 'sip.babble.net']

class PingTracker:
   def __init__(self):
       self.dns = None
       self.sip = None
       self.ping = None
   def gotSipServerResults(self, domain, test_opts):
       if domain:
           return siptest_f(domain, test_opts)
       raise ValueError("Error occured")
   def checkSIP(self, domain, test_opts):
       return threads.deferToThread(self.gotSipServerResults, domain, 

   def check(self, host, test_opts):
       checks = []
       return defer.gatherResults(checks)

   def setDNSResult(self, result):
       self.dns = result

   def setSIPResult(self, result):
       self.sip = result
   def setPingResult(self, result):       
       self.ping = result
   def SipCallback(self):
       print self.sip

test = PingTracker()
d = test.check(domain[0], test_opts)

print d  # this returns Deferred...

test.SipCallback()   # this returns None


More information about the Twisted-Python mailing list