Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Simple example showing why using super(self.__class__, self) is a BAD IDEA (tm)""" | |
class A(object): | |
def x(self): | |
print "A.x" | |
class B(A): | |
def x(self): | |
print "B.x" | |
super(B, self).x() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iter_group(queue): | |
buf = [] | |
prev_key = None | |
for val in queue: | |
cur_key, cur_val = val | |
#print cur_key, cur_val | |
if cur_key == prev_key or prev_key is None: | |
buf.append(cur_val) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple demonstration of how to implement Server-sent events (SSE) in Python | |
using Bottle micro web-framework. | |
SSE require asynchronous request handling, but it's tricky with WSGI. One way | |
to achieve that is to use gevent library as shown here. | |
Usage: just start the script and open http://localhost:8080/ in your browser. | |
Based on: |