Skip to main content
Build Status Coverage

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.

Got questions?

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:8000
app = EchoServer(8000)
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", 8000))
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 3.8, 3.9, 3.10, 3.11, 3.12, 3.13

  • pypy (the newer the better)

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 or the Downloads 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 are also several places you can reach out to the circuits community:


Disclaimer

Whilst I (James Mills) continue to contribute and maintain the circuits project I do not represent the interests or business of my employer Facebook Inc. The contributions I make are of my own free time and have no bearing or relevance to Facebook Inc.

Release files for circuits 3.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for circuits 3.2.5
File Size Uploaded
circuits-3.2.5.tar.gz 191.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for circuits 3.2.5
File Interpreter ABI Platform
circuits-3.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 343.9 kB

Release files / circuits-3.2.5.tar.gz

Download URL circuits-3.2.5.tar.gz
Size 191.8 kB
Tags Source
SHA-256 checksum
How to use checksums
867cbfc692a1aa45cf0aada1487988411bffb0271601f57712e5cccf3caf6034
BLAKE2b-256 checksum
How to use checksums
b3f9daa4fff4c1c350bd96835c591773ea517c6147b93c5b937d5c0dce91d097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / circuits-3.2.5-py3-none-any.whl

Download URL circuits-3.2.5-py3-none-any.whl
Size 152.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49a420b044ccb1def0434f75f2451472a110cabfbd0a1628eb0b4083986fe2ba
BLAKE2b-256 checksum
How to use checksums
857c00ed61f322c96519651e8031bf147b03b90a9cf74f0c8313f497fa37c210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

3.2.5 This release

2 release files

3.2.4

2 release files

3.2.3

1 release file

3.2.2

2 release files

3.2.1

2 release files

3.2

2 release files

3.1.0

3 release files

3.0

6 release files

2.1.0

7 release files

2.0.1

3 release files

2.0.0

2 release files

1.6

3 release files

1.5.1

2 release files

1.5

3 release files

1.4

3 release files

1.3.3

3 release files

1.3.2

3 release files

1.3.1

2 release files

1.3

1 release file

1.2.1

5 release files

1.2

2 release files

1.1.1

3 release files

1.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page