from __future__ import with_statement import pickle import struct import eventlet from eventlet.semaphore import Semaphore from drivel.utils.importing import import_preferential pickle = import_preferential("cPickle", "pickle") LEN_HEADER = struct.Struct(">I") class EOF(Exception): pass class Messaging(object): def __init__(self, sock, serialiser=pickle): self.sock = sock self.buff = "" self._ser = serialiser self._len = None self._bsz = 4096 self._sem = Semaphore() def fileno(self): return self.sock.fileno() def peek(self):
import sys import traceback import weakref # third-party imports import eventlet from eventlet import greenthread from eventlet import hubs from eventlet import wsgi from eventlet.green import time from webob import Request # local imports from drivel import component from drivel.auth import UnauthenticatedUser from drivel.utils import connwatch from drivel.utils.importing import import_preferential json = import_preferential('json', 'simplejson') class TimeoutException(Exception): pass class InvalidSession(Exception): pass class ConnectionReplaced(Exception): pass class ConnectionClosed(Exception):