Hang at commit time when using sftp or bzr+ssh
Aaron Bentley
aaron at aaronbentley.com
Thu Dec 8 18:30:33 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11-12-07 02:43 PM, Martin Pool wrote:
> On 8 December 2011 06:29, Stephen Auyeung <stephen at ck12.org>
> wrote:
>> Martin,
>>
>> I did not explicitly open new ssh transports. Was it done inside
>> commit? If so, why wasn't the disconnect called?
>
> OK, I think there is a bug where transports that are automatically
> opened from a url during an operation like this will not be closed
> automatically. It will only be a concrete problem in cases like
> yours where you have a long lived process opening multiple trees
> bound to remote locations, but it is worth fixing. We could add a
> __del__ method, or have some kind of scope that tells it when to
> disconnect.
Any time you're thinking about scopes and destructors, it's worth
considering using a ContextManager. The transport itself could
implement __exit__()
In order to call __exit__ on the transport, you might need to make
Branch also a context manager, but that's actually an idea I've had
for some time, in order to implement locking more reliably. Consider:
with Branch.open_read_locked(path) as branch:
# transport connection is active, branch is read-locked
branch.last_revision()
# transport connection is closed, branch is unlocked
print "done!"
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk7hAkkACgkQ0F+nu1YWqI0y4ACeINC4ARUIbfopWK7CO729UZrH
imIAnR4JTY3NxQm8SR9nLVKY9KiJKz+0
=63IQ
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list