This is one part of a production ready bitcoin mining pool written in pyhton 2.7 and twisted, it is event-driven, efficient and well tested. The rest of the code is kept private. See the launch script for an idea of how it looks like.
For examples of the usage, check this: https://github.com/frrp/btc_bits