circuits + twisted

circuits + twisted integration

Well I’ve finally gone and done it! It’s still alpha at this stage but twisted applications, protocols and libraries can now run on top of circuits.

Check out the code and samples:

All you need to do is install the CircuitsReactor at the top of your module:

import circuitsreactor

Here’s a simple “Echo Server” example straight from twisted’s docs:

#!/usr/bin/env python

import circuitsreactor

from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.endpoints import TCP4ServerEndpoint

class Echo(Protocol):

    def dataReceived(self, data):

class EchoFactory(Factory):

    def buildProtocol(self, addr):
        return Echo()

# 8007 is the port you want to run under. Choose something >1024
endpoint = TCP4ServerEndpoint(reactor, 8007)

Enjoy :)