Help trying to run selftest on EC2
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 2 17:41:20 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
> Anyone have any ideas about how to clear this up? Should I hack up an
> os.rename() that detects PermissionDenied, calls time.sleep() for a half
> second, and then tries again?
>
> John
> =:->
So I hacked together this:
=== modified file 'bzrlib/tests/__init__.py'
- --- bzrlib/tests/__init__.py 2009-11-30 20:33:06 +0000
+++ bzrlib/tests/__init__.py 2009-12-02 17:31:45 +0000
@@ -4447,3 +4447,25 @@
return result
except ImportError:
pass
+
+
+_orig_rename = os.rename
+def os_rename_hack(*args, **kwargs):
+ try:
+ return _orig_rename(*args, **kwargs)
+ except OSError, e:
+ if e.errno in (errno.EPERM, errno.EACCES):
+ try:
+ st = os.lstat(args[0])
+ except (OSError, IOError), e:
+ note('lstat failure %s for %s' % (errno.errorcode[e.errno],
+ args[0]))
+ st = None
+ note('%s while trying to rename %s %r, trying again.'
+ % (errno.errorcode[e.errno], st, args))
+ time.sleep(1.0)
+ return _orig_rename(*args, **kwargs)
+ # We don't re-raise, as we assume that
+ else:
+ raise
+os.rename = os_rename_hack
But it still fails (even with a 1.0s retry).
Does anyone know if there is a way to list open file handles for a
process? I don't really understand why renaming 'held' is failing. Since
we shouldn't have opened the info file after we renamed it from
'pending.*'. At least, I believe we don't peek until after we have
renamed it to 'releasing.*'.
Ah... I may have an idea. I think after we rename pending => held we
then peek at the info file to make sure we got the lock.
And looking at the read_info_file code, we do:
return self._parse_info(self.transport.get(path))
And *that* means we grab a file, which we then call '.readlines()', but
never call .close(). Which means that the file gets closed by the
deconstructor, which means it is being closed asynchronously. Which
*might* not happen before we go to rename the file. I'll try a patch for
that.
It doesn't explain why renaming the pack files is failing, as that looks
pretty explicit about calling "self.write_stream.close()" which I'm
pretty sure calls all the way down to doing a blocking close. But maybe
I can at least fix this problem.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAksWpsAACgkQJdeBCYSNAAPTLACfdiWQXabF6tQX8lr0YiVgdWF2
F2MAn3YCNb1QeScDoffNBMPWxKjjFYwN
=cdxx
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list