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 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, 3.4

  • 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

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.

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.tar.gz (2.1 MB view details)

Uploaded Source

Built Distributions

circuits-3.0-py3.4.egg (569.7 kB view details)

Uploaded Source

circuits-3.0-py3.3.egg (578.4 kB view details)

Uploaded Source

circuits-3.0-py3-none-any.whl (230.3 kB view details)

Uploaded Python 3

circuits-3.0-py2.7.egg (551.1 kB view details)

Uploaded Source

circuits-3.0-py2-none-any.whl (230.3 kB view details)

Uploaded Python 2

File details

Details for the file circuits-3.0.tar.gz.

File metadata

  • Download URL: circuits-3.0.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for circuits-3.0.tar.gz
Algorithm Hash digest
SHA256 04d6b322a629a18b87a5045bd09bab7e4a20bf7b3680814ada7ef3fdcc13bb3e
MD5 d46912fd517c72433b5820b1dab9e924
BLAKE2b-256 b7d10f232f52c24f9356108db185f64ee851dd1440fa2aaee168ce4e45f71a1d

See more details on using hashes here.

File details

Details for the file circuits-3.0-py3.4.egg.

File metadata

  • Download URL: circuits-3.0-py3.4.egg
  • Upload date:
  • Size: 569.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for circuits-3.0-py3.4.egg
Algorithm Hash digest
SHA256 d66f1b7ef9741257053726aa804688e6f4c30714fdb9e3629b424e57793776ee
MD5 f4e83f3c7cdc0144a5c8fcfde27c89ab
BLAKE2b-256 973d86bb5f20e560db1a3cdaf3d367a33e2e32ef37909f790d3d8d8709b28904

See more details on using hashes here.

File details

Details for the file circuits-3.0-py3.3.egg.

File metadata

  • Download URL: circuits-3.0-py3.3.egg
  • Upload date:
  • Size: 578.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for circuits-3.0-py3.3.egg
Algorithm Hash digest
SHA256 cad7873bb95e97f7aefe31bb03ce3944ab2cbaf849c7e513af05d55232a9707e
MD5 cf76a5a9138ef8718527d06de34cb4a3
BLAKE2b-256 af93b6ae1ca3b3c8c602d0101e34c7b151482e006cfa22e6cb1eda916c008923

See more details on using hashes here.

File details

Details for the file circuits-3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8174969710f9a852a17dc503a0e425edf516a13964e3ec7967456ff8cb656f9
MD5 5f898c0a375c699ee1e088d12c464345
BLAKE2b-256 719e9639611896065edf47036bf75477ce51465fbaef6130141be37325f2c6c3

See more details on using hashes here.

File details

Details for the file circuits-3.0-py2.7.egg.

File metadata

  • Download URL: circuits-3.0-py2.7.egg
  • Upload date:
  • Size: 551.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for circuits-3.0-py2.7.egg
Algorithm Hash digest
SHA256 8a2295e20b6d9aba288ff317782a423f7135828d6c7faafe1e917fab73eb1270
MD5 67d48435a88a6acab9820acbec7475cd
BLAKE2b-256 95f72d76be938a93ba0d7c2844d179b05b1bd9f3cb5f73e05ef28f3c1d60d6c8

See more details on using hashes here.

File details

Details for the file circuits-3.0-py2-none-any.whl.

File metadata

File hashes

Hashes for circuits-3.0-py2-none-any.whl
Algorithm Hash digest
SHA256 af061553eae6350efec48be642c081b1268a086880736039b017826d072691d1
MD5 9b38ff92326e9518570062d6da3ed755
BLAKE2b-256 705f35e8020afa162d4ca70ad22daf73cce99ef81dce83abb59b54e7d5b53327

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