Skip to main content

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.

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

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:

1 from circuits import Component
2 
3 class App(Component):
4 
5    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:

1 from circuits import Component
2 
3 
4 class App(Component):
5 
6    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:

 1 from circuits.net.sockets import TCPServer
 2 
 3 
 4 class EchoServer(TCPServer):
 5 
 6    def read(self, sock, data):
 7       return data
 8 
 9 
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:

1 from circuits import tick
2 
3 class MyComponent(Component):
4    @tick
5    def my_tick(self):
6       print '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.

 1 class A(Component):
 2 
 3     channel = "a"
 4 
 5     def foo(self):
 6         return "Hello"
 7 
 8 
 9 class B(Component):
10 
11     channel = "b"
12 
13     def foo(self):
14         return "World!"
15 
16 
17 class App(Component):
18 
19     def hello(self):
20         a = yield self.call(Event.create("foo"), "a")
21         b = yield self.call(Event.create("foo"), "b")
22         yield "{0} {1}".format(a, b)
23 
24 m = Manager() + Debugger()
25 A().register(m)
26 B().register(m)
27 App().register(m)
28 m.start()

For a full list of changes for this release see the Change Log.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuits-2.0.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

circuits-2.0.0-py2.6.egg (464.5 kB view details)

Uploaded Source

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

Hashes for circuits-2.0.0.tar.gz
Algorithm Hash digest
SHA256 98876be58d74beae9fe40e80b08478a5ed3884475ca937545200628948a1b24d
MD5 f911c5d9a8615f2ed40857526014aced
BLAKE2b-256 700b7e2e8fbddcfc91a3c8ddd9b53b5c1fc9034f4be1556cd3bc2ce503e1abbe

See more details on using hashes here.

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

Hashes for circuits-2.0.0-py2.6.egg
Algorithm Hash digest
SHA256 8b2cd0d0add5eb9cbcbce23291ee814fbdb8f039770c5b3d37a5cb464eb41f2d
MD5 bd9a19aeb69c3be4a0b175fee453634f
BLAKE2b-256 1a4873e7c159becaf2637b7361d61e91a5fccc98a6095f34d8ff206211a42a57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page