基于异步组件的事件应用框架

circuits的Python项目详细描述


Build StatusCoverageQualityStories ReadyRequirements Status

电路是由轻量级事件驱动和异步application framework用于Python Programming Language 具有一个强组件体系结构。

电路还包括轻量级、高性能和可扩展性 与http/wsgi兼容的web服务器以及各种i/o和网络 组件。

有问题吗?

示例

你好

#!/usr/bin/env python"""circuits Hello World"""fromcircuitsimportComponent,Eventclasshello(Event):"""hello Event"""classApp(Component):defhello(self):"""Hello Event Handler"""print("Hello World!")defstarted(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 EventraiseSystemExit(0)# Terminate the ApplicationApp().run()

回声服务器

#!/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.
"""fromcircuitsimporthandler,Debuggerfromcircuits.net.socketsimportTCPServerclassEchoServer(TCPServer):@handler("read")defon_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.
        """returndata# Start and "run" the system.# Bind to port 0.0.0.0:9000app=EchoServer(9000)Debugger().register(app)app.run()

你好网络

#!/usr/bin/env pythonfromcircuits.webimportServer,ControllerclassRoot(Controller):defindex(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()

更多examples

功能

  • 事件驱动
  • 并发支持
  • 组件架构
  • 异步I/O组件
  • 不需要外部依赖项
  • 全功能Web框架(circuits.web)
  • 基于协同路由的同步原语

要求

支持的平台

  • Linux、FreeBSD、Mac OS X、Windows
  • python 2.6、2.7、3.2、3.3、3.4
  • Pypy 2.0、2.1、2.2

安装

安装电路的最简单和推荐的方法是使用pip。 您可以使用pip安装pypi的最新稳定版本:

$ pip install circuits

如果您没有PIP,可以使用Easy_安装:

$ easy_install circuits

或者,您可以从 PyPiDownloads使用以下命令提取并安装:

$ python setup.py install

注意

您可以安装development version 通过pip install circuits==dev

许可证

电路是根据MIT License授权的。

反馈

我们欢迎任何关于bug的问题或反馈,以及关于如何 改进电路。

让我们知道你对电路的看法。@pythoncircuits

你有改进的建议吗?那么请Create an Issue 你想看什么的细节。我去看看然后 与你一起工作,要么融入这个想法,要么找到更好的解决方案。

社区

您还可以联系电路社区的几个地方:


免责声明

同时我(詹姆斯米尔斯)继续贡献和维护电路项目 我不代表我的雇主Facebook Inc.的利益或业务。 我的贡献是我自己的自由时间,没有任何意义 o Facebook公司

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我们应该在测试java代码时模拟黄瓜测试吗。我们应该在多大程度上使用黄瓜?   Hibernate Weblogic 10.3.4 java。lang.NoSuchMethodError:javax/persistence/spi/PersistenceUnitInfo。getValidationMode()Ljavax/persistence/ValidationMode;   java如何在main()中访问私有静态实例变量   java JMockit无法模拟类的公共final字段   java是否可以返回特定控制器操作的输出(html)?   java如何返回正确类型的列表?   rest-OpenUI/Swagger-java-to-API   java组织。springframework。豆。工厂NoSuchBeanDefinitionException或加载ApplicationContext失败   java使用POST将参数从JSP发送到Servlet   java如何监听特定的按钮按下和主视图用户交互?   java如何让gradle在本地maven repo中覆盖库?   如何在Java中“合并”两个URI?   java如何制作一个方法来移动数组中的字符?   使用来自java的命令启动powershell窗口   java垃圾收集器和匿名类   java如何为CellTable(GWT 2.4)中的ImageResourceCell创建PanelPopup?