Skip to content

Instantly share code, notes, and snippets.

View jdmaturen's full-sized avatar

jd jdmaturen

View GitHub Profile
"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` found in :mod:`pyzmq <zmq>` to be non blocking
"""
__zmq__ = __import__('zmq')
from gevent.hub import _threadlocal
from gevent.socket import wait_read, wait_write
__patched__ = ['Context', 'Socket']
globals().update(dict([(var, getattr(__zmq__, var))
for var in __zmq__.__all__
if not (var.startswith('__')
@dustin
dustin / flume.py
Created July 27, 2010 21:05
tap -> flume
#!/usr/bin/env python
#
# tap -> flume
#
# requires: python thrift bindings + compiled flume thrift binding.
#
import sys
import time
import struct
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."""