Skip to main content

Asynchronous Component based Event Application Framework

Project description

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.

Latest PyPI version Number of PyPI downloads Build Status Requirements Status

Examples

Hello

#!/usr/bin/env python

"""circuits Hello World"""

from circuits import Component, Event


class hello(Event):
    """hello Event"""


class App(Component):

    def hello(self):
        """Hello Event Handler"""

        print("Hello World!")

    def started(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 Event

        raise SystemExit(0)  # Terminate the Application

App().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.
"""

from circuits import handler, Debugger
from circuits.net.sockets import TCPServer


class EchoServer(TCPServer):

    @handler("read")
    def on_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.
        """

        return data

# Start and "run" the system.
# Bind to port 0.0.0.0:9000
app = EchoServer(9000)
Debugger().register(app)
app.run()

Hello Web

#!/usr/bin/env python

from circuits.web import Server, Controller


class Root(Controller):

    def index(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()

More examples

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

Requirements

Supported Platforms

  • Linux, FreeBSD, Mac OS X, Windows

  • Python 2.6, 2.7, 3.2, 3.3

  • pypy 2.0, 2.1, 2.2

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 extract it and install using:

> python setup.py install

You can also install th latest-development version using pip with pip install circuits==dev.

License

circuits is licensed under the MIT License.

Feedback

We 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 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.

Changes

circuits-3.0.dev

  • 10th Year Release

  • Improved Documentation

  • Improved API.

  • More Examples.

Download files

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

Source Distribution

circuits-3.0.0.dev.tar.gz (340.2 kB view details)

Uploaded Source

Built Distributions

circuits-3.0.0.dev-py33-none-any.whl (218.2 kB view details)

Uploaded Python 3.3

circuits-3.0.0.dev-py32-none-any.whl (218.2 kB view details)

Uploaded Python 3.2

circuits-3.0.0.dev-py27-none-any.whl (253.9 kB view details)

Uploaded Python 2.7

circuits-3.0.0.dev-py26-none-any.whl (218.2 kB view details)

Uploaded Python 2.6

circuits-3.0.0.dev-py3.3.egg (554.5 kB view details)

Uploaded Source

circuits-3.0.0.dev-py3.2.egg (540.0 kB view details)

Uploaded Source

circuits-3.0.0.dev-py2.7.egg (618.1 kB view details)

Uploaded Source

circuits-3.0.0.dev-py2.6.egg (528.3 kB view details)

Uploaded Source

File details

Details for the file circuits-3.0.0.dev.tar.gz.

File metadata

File hashes

Hashes for circuits-3.0.0.dev.tar.gz
Algorithm Hash digest
SHA256 3b9a637c37d4db7f4d7dbffb19552c8a504c372c748934e1709339e5079c5c5e
MD5 507c17fd85aac715df26913611a1e452
BLAKE2b-256 8e36405ecdf537b6ab647f4cbb8fe88cb897e78c5639fcc1eef71f0ca267b2c0

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py33-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py33-none-any.whl
Algorithm Hash digest
SHA256 5046e8acc99230453e16bb88203b596d8076b4ca3ebe178640c48924c818f85c
MD5 1bd80f1a2ddf7bacdd96990a8d45788d
BLAKE2b-256 c289bab480fa530187f791823c1a2951d670cfe743bb70eb91c919bc523bda1a

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py32-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py32-none-any.whl
Algorithm Hash digest
SHA256 d4989bc1a999facd2e19e8726243010f3a513c7058d3db6bf9cfbeb7c2085ff7
MD5 897831df9c1db4a4442f148966b796d0
BLAKE2b-256 5b62e6bcdd4f4b87f80c4176c7e87e7c051adde1b00c0a06e58ada0060a552c6

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py27-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py27-none-any.whl
Algorithm Hash digest
SHA256 411ceabddc0b8349ce5bd7447c09496cee09959ae33063f4eac72e5a6a336ede
MD5 36ca6fa5378b66a1c68dfcd5b1da23bb
BLAKE2b-256 b1e6b97cfcf9cfe666f16639e8b6f4976adaa6c92912a9d152684094192ad58f

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py26-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py26-none-any.whl
Algorithm Hash digest
SHA256 326e55e88e7d4ecc0513e57f8fa0950386fa877491a3ae7b522e41f456fbd6f3
MD5 9087780964a50c7c47dc27007d5b9be4
BLAKE2b-256 23ce6f034e0c2d1cdb684b59bb1b424ee76fb90b0ffcc6445d3668247d38f80c

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py3.3.egg.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py3.3.egg
Algorithm Hash digest
SHA256 ce0b198323d7dfba618a41ed57628465641c0fca0048f24796ebb15fefa3045b
MD5 a73dc4793d3a5946e9e89a56d8a95d5c
BLAKE2b-256 e2156310066313e2460a191ac0e142072b4bb4f79d76c490b6e814916b6fad6a

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py3.2.egg.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py3.2.egg
Algorithm Hash digest
SHA256 70ab0a93f92d211d65ca7c257b1bbe53f26828a045147acf7d2cd1a71696552f
MD5 85e0929233c8cc3a612a30f6e43c5d7a
BLAKE2b-256 3fb2a885fdd96d79a9a939771e14bdb768aad70b5d0bd0a920e372b0574a97c2

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py2.7.egg.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py2.7.egg
Algorithm Hash digest
SHA256 e350b17f27250957de5e8c90cd98ec3afa371c5b505f41f4de954a8320fb46d4
MD5 c6fa1ca434ac6ff5b28f4b948cb60b63
BLAKE2b-256 626942ea7b9fad07f9cceb56f1066eb99ef053369d6f3dab2b4f0e2f992a1132

See more details on using hashes here.

File details

Details for the file circuits-3.0.0.dev-py2.6.egg.

File metadata

File hashes

Hashes for circuits-3.0.0.dev-py2.6.egg
Algorithm Hash digest
SHA256 8ff6b429af6fec5af5e002d7f3511721298d685efb32f7ee6c0850b7c7966213
MD5 ffd4b24d0dbeb19655eca12835134ff3
BLAKE2b-256 ecbc5339bd1ba420eac78ae0c90e2b7cdd5cc2706e16e285dbe7ec4ce9312dac

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