Killing a blocking thread in python?

  • Post author:
  • Post category:Python

It seems that there is no way of killing a blocking thread in python? The standard way of implementing thread death seems to be to implement an exit() method on the class which is the thread, and then call that when you want the thread to die. However, if the run() method of the thread class is blocking when you call exit(), then the thread doesn't get killed. I can't find a way of killing these threads cleanly on Linux -- does anyone have any hints?

Continue ReadingKilling a blocking thread in python?

Death Bringer

  • Post author:
  • Post category:Book

I feel sorry for Jake Olsen. It must be hard having the ensign-in-the-red-shirt role. This book is as good as the rest of the series, and the First Family truly are bastards. I really liked this one. [isbn: 0747400016]

Continue ReadingDeath Bringer

Blood River

  • Post author:
  • Post category:Book

This is the fourth book in the Amtrak Wars series. Its pretty good, about the same level of writing as Cloud Warrior and Iron Master, which I guess means it was better than First Family (which was mostly a connector between the first and third books in the series). In this book we learn that the first family are even more nasty than previously disclosed, and that Cadillac is possibly the most annoying person on the planet. This book must not have been very popular in the US, because I've never seen it for sale in the US, but its reasonably common in Australia. That's a shame because the copy I have is about to fall apart, which means I'll have to wait until next time I am back home to try and find a replacement copy. Overall this book was quite readable, and I enjoyed it. [isbn: 0747400008]

Continue ReadingBlood River

Isaac Asimov’s Robot City: Suspicion

  • Post author:
  • Post category:Book

This is the second book in the Isaac Asimov's Robot City series, and follows on directly from Odyssey. In fact, it follows so closely that it feels like it should be part of that earlier book. I preferred this book to the first in the series, I suspect because it didn't need to use a random unexplained change to escape a dying plot line (which is what I felt happened about a third of the way through the first book). This book does feel a little juvenile though, but I forgive it.

Continue ReadingIsaac Asimov’s Robot City: Suspicion

PNGtools 0.4

  • Post author:
  • Post category:Pngtools

Wow, this is a blast from the past. When I wrote the pngchunks command in 2003, I had never seen a 64 bit machine, and knew enough to check that an int was the right size, but not enough to just use the guaranteed-to-be-32-bit version from day 1. I'd pretty much forgotten about this code until I got pinged about this Debian bug. The bug reporter is entirely right, this was lame. PNGtools 0.4 should be 64 bit safe. The pngchunks command works on my 64 bit machines at least. A historical note from November 2020: this code is quite old, but still actively used. I have therefore converted the old subversion repository to git and it is hosted at https://github.com/mikalstill/pngtools. I will monitor there for issues and patches and try my best to remember what I was thinking 20 years ago...

Continue ReadingPNGtools 0.4

Isaac Asimov’s Robot City: Odyssey

  • Post author:
  • Post category:Book

This is the first in a series of robot stories endorsed by Isaac Asimov. I enjoyed the first third of the book more than the last two thirds, mainly because I found the second two thirds a little hard to believe. Interestingly they were hard to believe in a similar manner to some of the Stainless Steel Rat books (such as The Stainless Steel Rat Saves the World, The Stainless Steel Rat Wants You, and The Stainless Steel Rat Goes to Hell). I wont get too specific, because I don't want to spoil the plot. This book felt kinda juvenile as well -- the plot lacked depth in my opinion. On the other hand, I did enjoy reading it, and it was better than I expected it to be.

Continue ReadingIsaac Asimov’s Robot City: Odyssey

Packet capture in python

  • Post author:
  • Post category:Python

I'm home sick with a cold today and got bored. I wanted to play with packet capture in python, and the documentation for pcapy is a little sparse. I therefore wrote this simple little sample script: #!/usr/bin/python # A simple example of how to use pcapy. This needs to be run as root. import datetime import gflags import pcapy import sys FLAGS = gflags.FLAGS gflags.DEFINE_string('i', 'eth1', 'The name of the interface to monitor') def main(argv): # Parse flags try: argv = FLAGS(argv) except gflags.FlagsError, e: print FLAGS print 'Opening %s' % FLAGS.i # Arguments here are: # device # snaplen (maximum number of bytes to capture _per_packet_) # promiscious mode (1 for true) # timeout (in milliseconds) cap = pcapy.open_live(FLAGS.i, 100, 1, 0) # Read packets -- header contains information about the data from pcap, # payload is the actual packet as a string (header, payload) = cap.next() while header: print ('%s: captured %d bytes, truncated to %d bytes' %(datetime.datetime.now(), header.getlen(), header.getcaplen())) (header, payload) = cap.next() if __name__ == "__main__": main(sys.argv) Which outputs something like this: 2008-11-25 10:09:53.308310: captured 98 bytes, truncated to 98 bytes 2008-11-25 10:09:53.308336: captured 66 bytes, truncated to 66 bytes 2008-11-25 10:09:53.315028: captured 66 bytes, truncated…

Continue ReadingPacket capture in python

Daggerspell

  • Post author:
  • Post category:Book

This is yet another book I read as a kid and liked. I must admit that I find the Celtic names used through out the book to be quite confusing, especially when there are multiple similar names in use at the same time. Despite that, I really enjoyed this book -- even though its a pretty classic formula story. [isbn: 0553565214;0586073159]

Continue ReadingDaggerspell

Foundation and Earth

  • Post author:
  • Post category:Book

I really like how Asimov wraps up the extended Foundation series. Specifically, I'd previously complained while reading Pebble in the Sky that it was hard to believe that everyone simply forgets that they originated on Earth -- this book and Foundation's Edge go a long way to resolving that annoyance for me. Its also good to find out what happened to Aurora and Solaria finally -- especially given the Solaria mystery has been bothering me since Robots and Empire. Speaking just about this book so a moment, I do find the use of sex as a plot development method quite odd. There are three examples that bother me -- when Bliss is slipped through interstellar customs with the explanation that she's just a whore and therefore not important enough to make an issue of; the second is when Trevize basically shags his way out of an awkward situation, despite the other protagonist being quite hostile initially; and finally where he bonks someone on a rural world. I find all three of those incidents a little out of place with the rest of the book, and in fact the rest of the series. Other authors use those kinds of plot elements,…

Continue ReadingFoundation and Earth

End of content

No more pages to load