Simple async w/o async
multitasking: Simple async w/o async
multitasking offers a simple method to convert Python methods into asynchronous / non-blocking methods by using decorators.
import multitasking import time import random import signal # kill all tasks on ctrl-c signal.signal(signal.SIGINT, multitasking.killall) # to wait for task to finish, use: # signal.signal(signal.SIGINT, multitasking.wait_for_tasks) @multitasking.task def hello(count): sleep = random.randint(1,10)/2 print("Hello %s (sleeping for %ss)" % (count, sleep)) time.sleep(sleep) print("Goodbye %s (after for %ss)" % (count, sleep)) if __name__ == "__main__": for i in range(0, 10): hello(i+1)
Install multitasking using pip:
$ pip install multitasking --upgrade --no-cache-dir
multitasking is distributed under the GNU Lesser General Public License v3.0. See the LICENSE.txt file in the release for details. multitasking is not a product of Interactive Brokers, nor is it affiliated with Interactive Brokers.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size multitasking-0.0.1.tar.gz (5.5 kB)||File type Source||Python version None||Upload date||Hashes View|