基于异步组件的事件应用框架
circuits的Python项目详细描述
电路是由轻量级事件驱动和异步application framework用于Python Programming Language 具有一个强组件体系结构。
电路还包括轻量级、高性能和可扩展性 与http/wsgi兼容的web服务器以及各种i/o和网络 组件。
有问题吗?
- Ask a Question(标记为:circuits-framework)
示例
你好
#!/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)
- 基于协同路由的同步原语
要求
- 除了Python Standard Library之外,电路没有依赖项。
支持的平台
- 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
或者,您可以从 PyPi或Downloads使用以下命令提取并安装:
$ python setup.py install
注意
您可以安装development version 通过pip install circuits==dev。
许可证
电路是根据MIT License授权的。
反馈
我们欢迎任何关于bug的问题或反馈,以及关于如何 改进电路。
让我们知道你对电路的看法。@pythoncircuits。
你有改进的建议吗?那么请Create an Issue 你想看什么的细节。我去看看然后 与你一起工作,要么融入这个想法,要么找到更好的解决方案。
社区
您还可以联系电路社区的几个地方:
- Mailing List
- Google+ Group
- #circuits IRC Channel在FreeNode IRC Network上
- Ask a Question在Stackoverflow(标记它:circuits-framework)
免责声明
同时我(詹姆斯米尔斯)继续贡献和维护电路项目 我不代表我的雇主Facebook Inc.的利益或业务。 我的贡献是我自己的自由时间,没有任何意义 o Facebook公司