Created
          December 16, 2014 23:02 
        
      - 
      
- 
        Save ilstar/32e265b36337828bc8f4 to your computer and use it in GitHub Desktop. 
    Python Ticker or thresholding
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from gevent import monkey;monkey.patch_all() | |
| import gevent | |
| import time | |
| import logging | |
| logging.basicConfig( level=logging.INFO, format="%(asctime)-15s %(message)s", datefmt="%Y-%m-%d %H:%M:%S") | |
| def timer(seconds, func): | |
| while True: | |
| logging.info('tick..') | |
| gevent.spawn(func) | |
| time.sleep(seconds) | |
| def task(): | |
| logging.info("work start") | |
| time.sleep(2) | |
| logging.info("work done") | |
| timer(5, task) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment