File: __init__.py

package info (click to toggle)
python-biopython 1.42-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 17,584 kB
  • ctags: 12,272
  • sloc: python: 80,461; xml: 13,834; ansic: 7,902; cpp: 1,855; sql: 1,144; makefile: 203
file content (17 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Deal with various biological databases and services on the web.
"""
import time

class RequestLimiter:
    # This class implements a simple countdown timer for delaying WWW
    # requests.
    def __init__(self, delay):
        self.last_time = 0.0
        self.delay = delay
    def wait(self, delay=None):
        if delay is None:
            delay = self.delay
        how_long = self.last_time + delay - time.time()
        if how_long > 0:
            time.sleep(how_long)
        self.last_time = time.time()