MCPcopy
hub / github.com/celery/celery / rate

Function rate

celery/utils/time.py:253–260  ·  view source on GitHub ↗

Convert rate string (`"100/m"`, `"2/h"` or `"0.5/s"`) to seconds.

(r: str)

Source from the content-addressed store, hash-verified

251
252
253def rate(r: str) -> float:
254 """Convert rate string (`"100/m"`, `"2/h"` or `"0.5/s"`) to seconds."""
255 if r:
256 if isinstance(r, str):
257 ops, _, modifier = r.partition('/')
258 return RATE_MODIFIER_MAP[modifier or 's'](float(ops)) or 0
259 return r or 0
260 return 0
261
262
263def weekday(name: str) -> int:

Callers 5

test_rate_limit_stringFunction · 0.90
_contextMethod · 0.90
rate_limitFunction · 0.90
bucket_for_taskMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 2

test_rate_limit_stringFunction · 0.72
_contextMethod · 0.72