Well… That Was Fun

Not really.

I’ve been working on a set of command-line utilities to let me post here without using an interactive browser. Reason is that WordPress is infected with excessive amounts of crap Javascript, to the point that its editor window is nearly useless if one doesn’t have a solid high-speed connection. Which I often don’t while commuting on the ferry.

Anyhow, two idiots have conspired to make my life more difficult than it needs to be. Both have used an object containing actual or implied time zone information to represent an XML-RPC date/time stamp (which doesn’t contain any time zone information).

Idiot No. 1 wrote the WordPress XML-RPC code (or the PHP library that uses same), and Idiot No. 2 wrote the Apache ws-xmlrpc code. Both idiots made feeble and ultimately failing attempts to defeat the lossage their idiocy begat, and I’ve spent most of the evening puzzling out the gyrations necessary to reverse engineer then counteract the lossage caused by both the base design flaw and the ineffectual original countermeasures… on both the client and server ends.

Yes, I’m being uncharitable and abrasive by calling those programmers “idiots”. You would too if your temper had just been worn thin by dealing with bizarre behavior caused by a stupid design decision.

Brexit Frankly Surprised Me

It does go to show that the sentiment which gave birth to the Trump phenomenon is not unique to the USA. As if there was ever any doubt. Italy had Berlusconi (and before that, Mussolini), France has the LePen family, Austria has a popular right-wing nationalist party, and so on. Smug Europeans have nothing to be smug about.

It’s a problems that has its roots in hierarchical class society. It doesn’t benefit the majority who live in it. The only way electoral democracy (or any open society) can be maintained under such a system is to have a powerful system of propaganda to keep the masses convinced to act counter to their best interests. And it has been shown, repeatedly, that the level of propaganda needed to do that, and the level of propaganda needed to sell fascism are dangerously close to each other

Reality-based politics is the only practical antidote to fascist myths, and that same reality is fatally toxic to class society, so absent revolutionary change it won’t happen and fascism will be an ever-present risk.

Beware Replacing os.spawn with subprocess.Popen in Python

This is going to be a very geeky post, but the bug in question just bit me and I am not aware of anyone else having written about it. Worse, the buggy code is actually recommended in the official Python documentation, which claims that the library call:

pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")

Can be replaced with:

pid = subprocess.Popen(["/bin/mycmd", "myarg"]).pid

It can’t. Not unless you want your child processes to mysteriously disappear on you without calls to os.wait() reflecting they’ve completed, that is.

The problem is that the suggested code immediately creates an unreferenced subprocess.Popen object, and this class declares a destructor (i.e. a __del__ method) which automatically reaps exited child processes at GC time. So the code in question creates a race condition as to which code will call os.wait() first: yours, or the destructor.

Arguably, subprocess.Popen should have an option to disable this feature (which is actually the correct behavior if you’re going to hang on to the Popen object and use it to manage the child process). Until such a time the workaround is to do something like:

class PopenNoDel(subprocess.Popen):
  """
  A Popen object that never gratuitously reaps dead children.
  """
  def __del__(self, **kwargs):
    pass

pid = PopenNoDel(["/bin/mycmd", "myarg"]).pid

Thankfully, it didn’t cause me much lost time. I had thought of the recommended code myself, then rejected the idea because of worries about gratuitous process reaping at GC time, and only changed my mind about the idea when the Python manual itself endorsed it. So the cause was fresh in my mind when my child processes started mysteriously vanishing.

Keywords: os.spawn, subprocess.Popen, wait, reap, garbage collector, subprocess, disappear, bug.

Zfacts Really Doesn’t Like Bernie

Partly it’s a misunderstanding of his democratic socialist politics. Partly it’s an understanding but a personal disagreement with them. It’s lead to several smear pieces about him on their site, some of which come across as downright conspiracist, predicting he will do his darndest to defeat Hillary even if that means helping Trump.

It seems the latter have just been proven wrong. It’s a cautionary tale about not letting your personal emotions about something get in the way of being able to perceive and interpret facts.

Remembering Muhammad Ali

I don’t follow sports much (never have, probably never will) but I came of age in the 1970s when Ali was making his comeback and it was hard not to be aware of him unless you were living under a rock.

But even then, the media mostly portrayed him as this talented boxer with a huge ego. (Both of which were aspects he indeed had, but which alone were an incomplete picture.)

It was only much later that I became aware of how much an amazing fighter he really was, both inside and outside the ring. He literally gave up the best years he could have had in his career as a professional boxer for his principles, principles that were based on fighting for a better world for the oppressed.

It’s a commitment to personal honor exceptionally rare in this world. (The only comparable example I can think of is Paul Robeson.)

Yes, he was in a sport that is now looked down on (in part because of outcomes like the early-onset Parkinson’s disease that Ali himself eventually succumbed to). Yes, in his early years he aligned themselves with the Nation of Islam and embraced their sometimes hateful rhetoric.

That just makes him a real person with real-world flaws who still achieved the greatness he did, which just makes me admire him all the more.