Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (33 sloc) 1.13 KB
import uwsgi
from bottle import route, default_app, request, response, redirect
def chat():
return """<iframe src="/recv"></iframe>
<iframe src="/sender"></iframe>"""
def sender():
return """<form method="GET" action="/send">
<textarea name="message"></textarea><br/>
<input type="submit" value="send" />
def recv():
response.header['Transfer-Encoding'] = 'chunked'
# this will flush headers
yield ""
running = True
while running:
# this will put the core in pause (for max 10 seconds) and remove it from the sched queue, so the /send can write to its socket
if not uwsgi.green_pause(10):
running = False
# this will maintain the connection opened if no data arrives
yield "<span/>"
def send():
# this will write to all the core in PAUSED state
uwsgi.green_write_all(request.GET['message'] + "<br/>")
# this will unpause all the paused cores, so they will be re-inserted in the sched queue
application = default_app()
Jump to Line
Something went wrong with that request. Please try again.