Monthly Archives: April 2008

comet chat in pylons (with cogen)

There is something very cool about wsgi: asynchronicity at it’s core ! The spec was made with this in mind – I absolutely love wsgi.
I’ve been playing recently with pylons and i’ve made a example chat app – just a proof-of-concept comet application with long pooling in a pylons app using a custom wsgi server [...]

setuptools + nosetests oddness

Looks like using setuptools’s test runner (eg, run python setup.py test) with the nose.collector has some weird issues – well, unexpected, for me at least.
I was using nose with coverage via –with-coverage option to get some cover reports. But setup.py test borked with “setup.py: error: no such option: –cover-package”. After some digging in the sources [...]

Qt reactor in cogen

I’ve implemented a reactor to integrate the cogen loop in the qt main loop.
You whould use it like this:

from PyQt4 import QtGui

app = QtGui.QApplication([])
hello = QtGui.QPushButton( "Hello world!" )
hello.resize(100, 30)
hello.show()

from cogen.core import reactors, schedulers
m = schedulers.Scheduler(reactor=reactors.QtReactor)

def lorem_ipsum_app(environ, start_response):
start_response(‘200 OK’, [('Content-type','text/plain'), ('Content-Length','19')])
return ['Lorem ipsum dolor..']

server = wsgi.WSGIServer(
[...]

Twitter fails at teh interwebs

I mean really, i would run a development site like that. I wonder where they learnt to do web programming since I see a bunch of failures:

javascripts aren’t concatenated, not even compressed – a lot of unnecessary http requests.
static content doesn’t have proper caching headers – more unnecessary http requests.
slow servers – i mean really, [...]

That history meme

Python version, shorter than Paddy’s version:

# history|python -c’import sys;c=[i.split()[1] for i in sys.stdin]; [sys.stdout.write("%s %s\n"%x) for x in sorted(set((c.count(i),i) for i in c), key=lambda (a,b):a)[::-1][:10]]’
198 python
71 ab
37 cat
36 /root/python/bin/python
31 cd
21 nc
21 strace
10 echo
9 history
8 easy_install

Still not shorter than the bash version:

history|awk ‘{a[$2]++} END{for(i in a){print a[i]" "i}}’|sort -rn|head

cogen and pylons can play !

Just so you know, cogen is a coroutine framework (based on the bidirectional generators from python 2.5) that has a wsgi server with some async extensions.
Straight to the point, i’m going to show the basics by building the backend of a web based (with comet-style ajax) irc client. This is a proof of concept and [...]

Curious difference between epoll, poll, kqueue and select

Suppose you have a brand new nonblocking socket and you want to do something with it (i have a connect in mind – but it’s irrelevant anyway). So what is your obvious choice for that since the socket is non-blocking ? Use select or poll or whatever ofcourse. Right? NO.
Sadly they don’t work the same [...]