Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

segmentio/gevent-ticker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gevent-ticker

pip install gevent_ticker

inspired by Golang's tickers

usage

from gevent_ticker import ticker, Ticker
import requests


# decorator
@ticker(times=20, period=100) # Max 100 requests every 20 seconds
def make_request(i):
  res = requests.get(...)
  return res.json()


# or DIY
loop = Ticker(20, 100)

for i in range(100):
  loop.next_tick()
  res = make_request()

  if res['done']:
    loop.stop()
    break

About

golang time.Ticker in python gevent

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages