One function

throttle in Suor/funcy

The author described this change as Fix @throttle() for timedelta arg. It counts as a record because the check below fails on the code as it stood at e50905919 and passes on 6c111987f, with nothing else changed between the two runs.

ProjectSuor/funcy
Fix saved2021-05-09
Sharing licenceBSD-3-Clause · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Allows only one run in a period, the rest is skipped

The change

11 def throttle(period):
22 """Allows only one run in a period, the rest is skipped"""
33 if isinstance(period, timedelta):
4- period = timedelta.total_seconds()
4+ period = period.total_seconds()
55
66 def decorator(func):
77 func.blocked_until = None

The check that tells the two apart

failpass·tests/test_flow.py::test_throttle[timedelta]

Check file tests/test_flow.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ite5090591930fffdde1688fa086274b7b0e6ccc06
Broken version dated2021-05-08
Modulefuncy.flow
Units changedthrottle
Fingerprint9c20efe666c53fc2
Checked2026-08-17 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in Suor/funcy