test: Replace threading with concurrent.futures #27287

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2303-test-check-return-value-😝 changing 2 files +30 −32
  1. maflcko commented at 8:59 AM on March 21, 2023: member

    threading has no easy way to get the return value or exception once the target function stops. Not checking the return value or exception can make tests more fragile and failures harder to debug.

    Fix this by checking the return value (or exception) by wrapping the function execution into a future and calling result() on it.

    Can be reviewed with --ignore-all-space.

    (There are still some uses of threading around, because some tests do expect an exception to be thrown and caught in the target function)

  2. test: Replace threading with concurrent.futures fa0696e786
  3. DrahtBot commented at 8:59 AM on March 21, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK ishaanam, stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label Tests on Mar 21, 2023
  5. fanquake requested review from ishaanam on Mar 21, 2023
  6. ishaanam commented at 11:23 PM on March 21, 2023: contributor

    ACK fa0696e7863af03efbffa026c2060ff2b5720fb1 Thanks for working on this, these changes should help figure out the occasional failures.

  7. maflcko assigned fanquake on Mar 22, 2023
  8. in test/functional/wallet_importdescriptors.py:694 in fa0696e786
     690 | @@ -691,25 +691,24 @@ def run_test(self):
     691 |          descriptor["next_index"] = 0
     692 |  
     693 |          encrypted_wallet.walletpassphrase("passphrase", 99999)
     694 | -        t = threading.Thread(target=encrypted_wallet.importdescriptors, args=([descriptor],))
     695 | +        with concurrent.futures.ThreadPoolExecutor(max_workers=1) as thread:
    


    stickies-v commented at 1:58 PM on March 23, 2023:

    nit: I think thread is a misnomer, even with just 1 worker it's still a pool or executor.

  9. stickies-v approved
  10. stickies-v commented at 2:11 PM on March 23, 2023: contributor

    ACK fa0696e7863af03efbffa026c2060ff2b5720fb1

  11. fanquake merged this on Mar 23, 2023
  12. fanquake closed this on Mar 23, 2023

  13. maflcko deleted the branch on Mar 23, 2023
  14. sidhujag referenced this in commit e08d5bf0bb on Mar 24, 2023
  15. bitcoin locked this on Mar 22, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-24 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me