def settle_card_holds(self, cursor, holds):
        log("Settling card holds.")
        participants = cursor.all("""
            SELECT *
              FROM payday_participants
             WHERE new_balance < 0
        """)
        participants = [p for p in participants if p.id in holds]

        log("Capturing card holds.")
        # Capture holds to bring balances back up to (at least) zero
        def capture(p):
            amount = -p.new_balance
            capture_card_hold(self.db, p, amount, holds.pop(p.id))
        threaded_map(capture, participants)
        log("Captured %i card holds." % len(participants))

        log("Canceling card holds.")
        # Cancel the remaining holds
        threaded_map(cancel_card_hold, holds.values())
        log("Canceled %i card holds." % len(holds))
dataset/ETHPy150Open gratipay/gratipay.com/gratipay/billing/payday.py/Payday.settle_card_holds/original