[Twisted-Python] Retry: Conch Issues

Jean-Paul Calderone exarkun at twistedmatrix.com
Fri Sep 25 04:40:33 MDT 2020


On Thu, Sep 24, 2020 at 8:54 PM Robert DiFalco <robert.difalco at gmail.com>
wrote:

> Why exactly is makeDirectory not firing any callbacks or errbacks and what
> can I add at the Factory level to make it do so?
>

class MySSHClientFactory(SSHClientFactory):
>     def clientConnectionLost(self, connector, reason):
>         self.op.addErrback(reason)
>
>     def makeDirectory(self, path, attrs):
>         self.op = Deferred()
>         def _cbSuccess(result):
>             self.op.callback(result)
>
>         return self.sftpClient.makeDirectory(path, attrs).addCallback(_cbSuccess)d
>
>
This code is wrong.  It takes what *may* be a perfectly good Deferred from
makeDirectory and breaks the error chain off of it.  The correct way to do
this would be more like `makeDirectory(...).chainDeferred(self.op)`.
However, `self.op` and `_cbSuccess` are doing nothing useful here so you
may as well just delete all that and return the `makeDirectory(...)`
Deferred.

If *that* Deferred doesn't fire its errback chain when the connection is
closed, that's a bug in Conch.  If you can put together a minimal example
and file a ticket, that would be wonderful and perhaps someone can get it
fixed for you.

Jean-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200925/dc2984ca/attachment-0001.htm>


More information about the Twisted-Python mailing list