circuits is a Lightweight Event driven and Asynchronous Application Framework for the Python Programming Language with a strong Component Architecture.
circuits also includes a lightweight, high performance and scalable HTTP/WSGI compliant web server as well as various I/O and Networking components.
Features*
- event driven
- concurrency support
- component architecture
- asynchronous I/O components
- no required external dependencies
- full featured web framework (circuits.web)
- coroutine based synchronization primitives
Examples*
from __future__ import print_function
from circuits import Component, Event
class hello(Event):
"""hello Event"""
class App(Component):
def hello(self):
print("Hello World!")
def started(self, component):
self.fire(hello())
raise SystemExit(0)
App().run()
A simple Echo Server:
from circuits.net.sockets import TCPServer
class EchoServer(TCPServer):
def read(self, sock, data):
return data
EchoServer(("0.0.0.0", 8000)).run()
A simple Web Application:
from circuits.web import Server, Controller
class Root(Controller):
def index(self):
return "Hello World!"
(Server(("0.0.0.0", 9000)) + Root()).run()