Python Generator Tricks for Systems Programmers
dabeaz.com
dabeaz.com
If anyone has the chance to listen to him speak or teach, I highly recommend it. (Also, if anyone has the chance to see him perform jazz music, I highly recommend that, too!)
def ping():
while ping_channel.receive(): #blocks here
print "PING"
pong_channel.send("from ping")
def pong():
while pong_channel.receive():
print "PONG"
ping_channel.send("from pong")
Most of the things that he has in there don't need to be done with generators, though generators make it more efficient and arguably cleaner. However, sometimes generators are just a twisted workaround for controlling program flow. Channels and tasklets in Stackless express program flow very well, in my opinion.You can see more of what stackless has to offer here: http://members.verizon.net/olsongt/stackless/why_stackless.h...
depending on what you are sending there are several alternatives for serializing data. there are a handful of json libraries to take a look at and some good benchmarks if you google for them.
Parent poster meant signing the pickled data as a text stream, not as a collection of unserialized python objects. If the signatures don't match, you just discard the data, and don't unpickle it.
This guarantees that (as long as your keys aren't compromised, and your signing algorithm is unbroken) you will never unpickle tampered-with data.