-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Prefer wait_until over polling with time.sleep #12553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
test/functional/feature_pruning.py
Outdated
if time.time() - waitstart > 30: | ||
raise AssertionError("blk00000.dat not pruned when it should be") | ||
# Wait for blk00000.dat to be pruned | ||
wait_until(lambda: not os.path.isfile(self.prunedir+"blk00000.dat"), timeout=30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is just preserving the previous code, but this should probably be updated to use os.path.join
like:
# Before
os.path.isfile(self.prunedir+"blk00000.dat")
# After
os.path.isfile(os.path.join(self.prunedir, "blk00000.dat"))
There are several instances of this unrelated to this PR, so perhaps it can just be done in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks there were a few such cases in this file, but not elsewhere.
utACK 3a1fc66cd09ff9bb1cda68683e855b507409aabf |
test/functional/feature_pruning.py
Outdated
@@ -262,7 +255,7 @@ def prune(index, expected_ret=None): | |||
assert_equal(ret, expected_ret) | |||
|
|||
def has_block(index): | |||
return os.path.isfile(self.options.tmpdir + "/node{}/regtest/blocks/blk{:05}.dat".format(node_number, index)) | |||
return os.path.isfile(os.path.join(self.options.tmpdir, "node{}".format(node_number), "regtest", "blocks", "blk{:05}.dat".format(index))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could use shorter code by referring to TestNode.datadir
:
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, 'regtest', 'blocks', 'blk{:05}.dat'.format(index)))
utACK 9d7f839 |
9d7f839 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b0822 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on #12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect #12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
Github-Pull: bitcoin#12553 Rebased-From: 81b0822
Github-Pull: bitcoin#12553 Rebased-From: 81b0822
9d7f839 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b0822 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on bitcoin#12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect bitcoin#12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
9d7f839 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b0822 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on bitcoin#12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect bitcoin#12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
9d7f839 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b0822 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on bitcoin#12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect bitcoin#12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
9d7f839 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b0822 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on bitcoin#12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect bitcoin#12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
This is prompted by and builds on #12545, a nice cleanup / consolidation of patterns.
In cases where the exception message was meaningful, I tried to represent it as well in a comment.
I expect #12545 will go in first, but I'm happy to squash them if that's preferred.