This file contains 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
''' | |
A Non blocking task scheduler and executor implemented using co routines and Tornado | |
Torando components acts as a non blocking listener and the 2 co routines scheduler and task exectutor | |
''' | |
import tornado.ioloop | |
import tornado.web | |
import tornado.httpserver | |
import tornado.gen | |
import time |
This file contains 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
#Pseduo python code | |
class HttpDownload(object): | |
def __init__(self,job,ioloop): | |
self.ioloop = ioloop | |
#create async http request | |
self.http_client = tornado.httpclient.AsyncHTTPClient() | |
self.http_client.fetch(self.req, self.async_callback) | |
def async_callback(self,reponse): |
This file contains 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
""" | |
Dump python object | |
@author: Not sure, had this code snippet, happy to attribute to who wrote this, saving for personal use | |
""" | |
def printDict(di, format="%-25s %s"): | |
for (key, val) in di.items(): | |
print format % (str(key)+':', val) | |
def dumpObj(obj, maxlen=77, lindent=24, maxspew=600): | |
"""Print a nicely formatted overview of an object. |
This file contains 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
#!/usr/bin/env python | |
""" | |
@author Sunil Mallya | |
Sample code to show a parent - child like process communication model where parent listens on a port and passes the pickled file descriptor | |
to the child process to read the bytes off the socket. The communication in this snippet is via a Queue which is thread/process safe | |
Just to be clear, the parent process is still accepting the connection and we are sending a live fd to the child | |
""" | |
import os | |
import sys |
NewerOlder