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
from gevent import monkey; monkey.patch_all() | |
import gevent | |
import gevent.greenlet | |
from functools import partial | |
from random import random | |
import urllib | |
import urllib2 | |
def on_exception(fun, greenlet): |
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
# Class for managing multiple servers or anything with start() and stop() methods | |
class ServerRack(object): | |
def __init__(self, servers): | |
self.servers = servers | |
def start(self): | |
started = [] | |
try: |
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
import gevent | |
from thrift.server.TServer import TServer | |
# XXX Hackish, but should be safe: monkey patch gevent socket support into | |
# Thrift. Overall I think this is cleaner than reimplementing all of TSocket. | |
from thrift.transport import TSocket; TSocket.socket = gevent.socket | |
from thrift.transport.TTransport import TTransportException | |
class TGEventServer(TServer): | |
"""Gevent socket server.""" |