Created
February 25, 2015 21:12
-
-
Save Williangalvani/599821f6541449206bfd to your computer and use it in GitHub Desktop.
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
GNU nano 2.2.6 File: threads.py | |
import threading | |
import threadly | |
import time | |
def motor(): | |
print "Motor", time.time() | |
def controle(): | |
print "controle", time.time() | |
executor = threadly.Executor(2) #starts a thread pool with 2 threads | |
#these execute the task asap | |
#this will Execute a task in 100 ms | |
executor.schedule(controle, delay=100, recurring=True) | |
#this will Execute a task every second until removed | |
executor.schedule(motor, delay=10, recurring=True) | |
time.sleep(5) | |
#this shuts down the threadpool | |
executor.shutdown() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment