Hello,
I have a small problem. I using SMTPClient and ClientFactory in order to send 
emails. I have something like:    observer['workers'] = total mails to 
send(connections)
    
    def got_result(*args):
        observer['results'] += 1

    def got_error(err):
        observer['errors'] += 1

    def got_end(_):
        if observer['results'] + observer['errors'] == observer['workers']:
            reactor.stop()

    factory = SomeFactory(...)    reactor.connectTCP(...)
    d.addCallbacks(got_result, got_error)
    d.addBoth(got_end)

class SomeFactory(ClientFactory):

    def clientConnectionLost(self, connector, reason):
        self.error_handle(reason)

    def error_handle(self, reason):
        if self.deferred is not None:
            d, self.deferred = self.deferred, None
            d.errback(reason)


Everything  is working ok if I don't have errors like: [Failure instance: 
Traceback (failure with no frames): <class 
'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost 
in a non-clean fashion: Connection lost.When I have a error like that, the 
rector is not stopping because the error counter is not incrementing. But when 
I kill the reactor, got_error() receive the errors and observer['results'] + 
observer['errors'] == observer['workers'] is evaluated and the reactor 
stops(with a error of course, Can't stop reactor that isn't running :)).

I don't understand how can I make this work. Can someone help me?
Thanks,

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to