Asynchronous Component based Event Application Framework
Project description
Overview
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.
To take full advantage of circuits and its architecture, circuits requires that your application be designed in terms of components and their interactions (events) with each other. An application written using the circuits application framework is maintainable, scalable and easy to develop.
circuits’ Loosely Coupled Component Architecture allows for a high level of Reuse and Scalability. Components are Componsable and much of the component library that circuits ships with are implemented as composed components.
Documentation: http://packages.python.org/circuits or Read the Docs.
Project website: https://bitbucket.org/prologic/circuits/
PyPI page: http://pypi.python.org/pypi/circuits
Features
event driven
concurrency support
component archiecture
asynchronous I/O components
no required external dependencies
full featured web framework (circuits.web)
coroutine based synchronization primitives
Requirements
circuits has no dependencies beyond the Python Standard Library.
Python: >= 2.6
Installation
The simplest and recommended way to install circuits is with pip. You may install the latest stable release from PyPI with pip:
> pip install circuits
If you do not have pip, you may use easy_install:
> easy_install circuits
Alternatively, you may download the source package from the PyPi Page or the Downloads page on the Website; extract it and install using:
> python setup.py install
License
circuits is licensed under the MIT License.
Feedback
Do you have suggestions for improvement? Then please Create an Issue with 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.
Community
There is also a small community of circuits enthusiasts that you may find on the #circuits IRC Channel on the FreeNode IRC Network and the Mailing List.
Release Notes - circuits-2.0.0 (cheetah)
Component Initialization
Implemented Component.init() support whereby one can define an alternative init() without needing to remember to call super(...) init() takes the same arguments as the normal __init__(...) constructor.
Example:
1from circuits import Component
23
class App(Component):
45
def init(self, ...):
6...
Component Singleton Support
No. This isn’t anything crazy bout restricting what you can do with components. This new feature allows you as a developer to restrict how many instances of any given component can be running in any given system.
Say you defined a Logger Component but you only wanted and designed for only one instance ever running in a single system. This is how you do it:
1from circuits import Component
23
4
class App(Component):
56
singleton = True
More Convenience for I/O Components
All I/O Components now implement the value_changed Event Notification API allowing you to define read Event Handlers that simply return responses.
Example:
1from circuits.net.sockets import TCPServer
23
4
class EchoServer(TCPServer):
56
def read(self, sock, data):
7return data
89
10
EchoServer(8000).run()
Tick Functions are now decorators!
In previous releases of circuits, a Component could only have a single __tick__ (Tick Function). This restriction is now gone and we’ve made it much simpler to define new Tick Functions by simply using the new @tick decorator.
Example:
1from circuits import tick
23
class MyComponent(Component):
4@tick
5def my_tick(self):
6print 'time is passing'
callEvent/waitEvent Enhancements
In circuits-1.6 we introduced two new primitives.
.callEvent(...)
.waitEvent(...)
These two primitives introduced synchronous features to the circuits framework allowing you to pause the execution of an event handler and write almost synchronous-style code whilst remaining asynchronous in the background.
Here are the list of improvements and an example to go with.
The .call(...) and .wait(...) synchronous primitives in this release are now implemented as co-routines using standard Python generators. (Previously they were implemented using greenlets).
The API are identical to that of fire(...)
Added the ability to return values from callEvent
Added the ability to yield from an event handler.
1class A(Component):
23
channel = "a"
45
def foo(self):
6return "Hello"
78
9
class B(Component):
1011
channel = "b"
1213
def foo(self):
14return "World!"
1516
17
class App(Component):
1819
def hello(self):
20a = yield self.call(Event.create("foo"), "a")
21b = yield self.call(Event.create("foo"), "b")
22yield "{0} {1}".format(a, b)
2324
m = Manager() + Debugger()
25A().register(m)
26B().register(m)
27App().register(m)
28m.start()
For a full list of changes for this release see the Change Log.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file circuits-2.0.0.tar.gz
.
File metadata
- Download URL: circuits-2.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98876be58d74beae9fe40e80b08478a5ed3884475ca937545200628948a1b24d |
|
MD5 | f911c5d9a8615f2ed40857526014aced |
|
BLAKE2b-256 | 700b7e2e8fbddcfc91a3c8ddd9b53b5c1fc9034f4be1556cd3bc2ce503e1abbe |
File details
Details for the file circuits-2.0.0-py2.6.egg
.
File metadata
- Download URL: circuits-2.0.0-py2.6.egg
- Upload date:
- Size: 464.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b2cd0d0add5eb9cbcbce23291ee814fbdb8f039770c5b3d37a5cb464eb41f2d |
|
MD5 | bd9a19aeb69c3be4a0b175fee453634f |
|
BLAKE2b-256 | 1a4873e7c159becaf2637b7361d61e91a5fccc98a6095f34d8ff206211a42a57 |