本文整理汇总了Python中backend.Backend.start方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.start方法的具体用法?Python Backend.start怎么用?Python Backend.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Backend
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import start [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from backend import Backend
backend = Backend()
backend.start()
while True: # spin the main thread, wait for notifications from sensors
try:
time.sleep(0.5)
except KeyboardInterrupt:
break
backend.stop()
print "Finished"
示例2: Flask
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import start [as 别名]
app = Flask(__name__)
app.config.from_pyfile('application.cfg', silent=True)
app.logger.setLevel(app.config['LOGLEVEL'])
sockets = Sockets(app)
redis = redis.from_url(app.config['REDIS_URL'])
cwd = os.path.dirname(os.path.realpath(__file__))
# Re build client and image each time so we don't get all the old logs
docker = Docker.Client(base_url='unix://var/run/docker.sock',
version='1.9',
timeout=5)
editors = Backend(redis, app.config['REDIS_CHAN'])
editors.start()
@app.route('/', defaults={'room':'default'})
@app.route('/<room>')
def index(room):
return render_template('index.html', room=room)
@sockets.route('/ws/submit/<room>')
def inbox(ws, room):
"""Receives incoming messages, inserts them into Redis."""
while ws.socket is not None:
# Sleep to prevent *constant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
if not message: