Skip to content

Instantly share code, notes, and snippets.

View icsaas's full-sized avatar
🎯
saasing

iac icsaas

🎯
saasing
View GitHub Profile
@icsaas
icsaas / processhandler.py
Created March 18, 2014 06:47
nonblocking process in tornado
class BaseRequestHandler(tornado.web.RequestHandler):
'''An non-blocking process
Example usage:
class MainHandler(srmlib.BaseRequestHandler):
@tornado.web.asynchronous
def get(self):
self.call_subprocess('sleep 5; cat /var/run/syslog.pid', self.async_callback(self.on_response))
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
from collections import namedtuple
from pymongo import MongoClient
from flask import request
from core.web.site import app
from core.web.site.views_master import *
import json
'''
$('#companies').dataTable( {
"bProcessing": true,
This Gist is for my post: http://www.andretw.com/2013/10/What-you-should-know-before-using-DataTables.html
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
pass
class HandlerMixin(object):
listeners = []
@icsaas
icsaas / par.py
Created February 14, 2014 06:33 — forked from lbolla/par.py
from threading import Thread
def busy_sleep(n):
while n > 0:
n -= 1
N = 99999999
t1 = Thread(target=busy_sleep, args=(N, ))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def authenticated(method):
"""Decorate methods with this to require that the user be logged in."""
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
if not self.current_user:
if self.request.method == "GET":
url = self.get_login_url()
if "?" not in url:
url += "?" + urllib.urlencode(dict(next=self.request.uri))
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)