Package: circuits
circuits is aLightweightEventdriven andAsynchronousApplication Frameworkfor thePython Programming Languagewith a strongComponentArchitecture.circuits also includes a lightweight, high performance and scalable
HTTP/WSGI compliant web server as well as various I/O and Networking
components.WebsiteDownloadsDocumentationGot questions?Ask a Question(Tag it:circuits-framework)ExamplesHello#!/usr/bin/env python"""circuits Hello World"""fromcircuitsimportComponent,Eventclasshello(Event):"""hello Event"""classApp(Component):defhello(self):"""Hello Event Handler"""print("Hello World!")defstarted(self,component):"""Started Event Handler

        This is fired internally when your application starts up and can be used to
        trigger events that only occur once during startup.
        """self.fire(hello())# Fire hello EventraiseSystemExit(0)# Terminate the ApplicationApp().run()Echo Server#!/usr/bin/env python"""Simple TCP Echo Server

This example shows how you can create a simple TCP Server (an Echo Service)
utilizing the builtin Socket Components that the circuits library ships with.
"""fromcircuitsimporthandler,Debuggerfromcircuits.net.socketsimportTCPServerclassEchoServer(TCPServer):@handler("read")defon_read(self,sock,data):"""Read Event Handler

        This is fired by the underlying Socket Component when there has been
        new data read from the connected client.

        ..note :: By simply returning, client/server socket components listen
                  to ValueChagned events (feedback) to determine if a handler
                  returned some data and fires a subsequent Write event with
                  the value returned.
        """returndata# Start and "run" the system.# Bind to port 0.0.0.0:9000app=EchoServer(9000)Debugger().register(app)app.run()Hello Web#!/usr/bin/env pythonfromcircuits.webimportServer,ControllerclassRoot(Controller):defindex(self):"""Index Request Handler

        Controller(s) expose implicitly methods as request handlers.
        Request Handlers can still be customized by using the ``@expose``
        decorator. For example exposing as a different path.
        """return"Hello World!"app=Server(("0.0.0.0",9000))Root().register(app)app.run()Moreexamples…Featuresevent drivenconcurrency supportcomponent architectureasynchronous I/O componentsno required external dependenciesfull featured web framework (circuits.web)coroutine based synchronization primitivesRequirementscircuits has no dependencies beyond thePython Standard Library.Supported PlatformsLinux, FreeBSD, Mac OS X, WindowsPython 2.7, 3.4, 3.5, 3.6pypy (the newer the better)InstallationThe simplest and recommended way to install circuits is with pip.
You may install the latest stable release from PyPI with pip:$ pip install circuitsIf you do not have pip, you may use easy_install:$ easy_install circuitsAlternatively, you may download the source package from thePyPior theDownloadsextract it and install using:$ python setup.py installNoteYou can install thedevelopment versionviapip installcircuits==dev.Licensecircuits is licensed under theMIT License.FeedbackWe welcome any questions or feedback about bugs and suggestions on how to
improve circuits.Let us know what you think about circuits.@pythoncircuits.Do you have suggestions for improvement? Then pleaseCreate an Issuewith details of what you would like to see. I’ll take a look at it and
work with you to either incorporate the idea or find a better solution.CommunityThere are also several places you can reach out to the circuits community:Mailing ListGoogle+ Group#circuits IRC Channelon theFreeNode IRC NetworkAsk a QuestiononStackoverflow(Tag it:circuits-framework)DisclaimerWhilst I (James Mills) continue to contribute and maintain the circuits project
I do not represent the interests or business of my employer Facebook Inc. The
contributions I make are of my own free time and have no bearing or relevance
to Facebook Inc.