Is there a generic notion of asynchronous programming in python? Could I assign a callback to a function, execute it and return to the main program flow immediately, no matt
You may see my Python Asynchronous Programming tool: http://www.ideawu.com/blog/2010/08/delegate-in-pythonpython-asynchronous-programming.html
import time, random, sys
from delegate import *
def proc(a):
time.sleep(random.random())
return str(a)
def proc_callback(handle, args=None):
ret = d.end(handle)
d = Delegate()
d.init(2) # number of workers
handle = d.begin(proc, '12345', proc_callback, 'test')
sys.stdin.readline()
d.free()