Sunday, September 19, 2010

Python: NetStack/CoreAsync

Today I've added to my GitHub Respositories NetStack/CoreAsync a python "package" (It's much more a bunch of utility classes) that allows you to code in async/parallel way, that I use to build my networking apps.
def concurrent_func(text):
    for i in range(5):
        print text, 'STEP', i

coreasync.dispatch_concurrent(lambda: concurrent_func("Context 1"))
coreasync.dispatch_concurrent(lambda: concurrent_func("Context 2"))

Package contains a small Async HTTP Server implementation that you can easily use:
def handle_response(socket, addr, request, headers, body):
   yield socket.send(...)

def handle_error(socket, addr, error):
   yield socket.send(...)

coreasync.httpserver.httpServerLoop(HOST, PORT, handle_response, handle_error)
print 'HTTP Server is Running on', HOST, PORT

You can find Source Code and Examples at GitHub:
git clone

1 comment:

  1. Exactly what I need for my current project :D (you know what I'm talking about :P)