I have ranted about the iPhone’s horrible iPod interface in the past, and any improvement they can make is certainly welcome. But the improvements in the iPhone OS 3.0 update seem more half-assed than a true solution. Yes, the ability to skip back 30 seconds will be nice, but it’s still a ham-fisted solution to the problem of exact scrolling inside a 70 minute podcast. And the “scrubber” interface seems complicated and error-prone.

The frustrating thing is that Apple already has the One True User Interface for playing audio: the click-wheel. With its handling of acceleration you can both seek through hours of audio extremely quickly while still giving you the one-second resolution to seek to the exact point you want, and I don’t understand why it isn’t emulated on the iPhone and iPod touch. At this point, I have to believe that there is some limitation of the touchscreen hardware which prevents it. Sigh.

The other day at work we encountered an unusual exception in our nightly pounder test run after landing some new code to expose some internal state via a monitoring API. The problem occurred on shutdown. The new monitoring code was trying to log some information, but was encountering an exception. Our logging code was built on top of Python’s logging module, and we thought perhaps that something was shutting down the logging system without us knowing. We ourselves never explicitly shut it down, since we wanted it to live until the process exited.

The monitoring was done inside a daemon thread. The Python docs say only:

A thread can be flagged as a “daemon thread”. The significance of this flag is that the entire Python program exits when only daemon threads are left. “

Which sounds pretty good, right? This thread is just occasionally grabbing some data, and we don’t need to do anything special when the program shuts down. Yeah, I remember when I used to believe in things too.

Despite a global interpreter lock that prevents Python from being truly concurrent anyway, there is a very real possibility that the daemon threads can still execute after the Python runtime has started its own tear-down process. One step of this process appears to be to set the values inside globals() to None, meaning that any module resolution results in an AttributeError attempting to dereference NoneType. Other variations on this cause TypeError to be thrown.

The code which triggered this looked something like this, although with more abstraction layers which made hunting it down a little harder:

try:
    log.info("Some thread started!")
    try:
        do_something_every_so_often_in_a_loop_and_sleep()
    except somemodule.SomeException:
        pass
    else:
        pass
finally:
    log.info("Some thread exiting!")

The exception we were seeing was an AttributeError on the last line, the log.info() call. But that wasn’t even the original exception. It was actually another AttributeError caused by the somemodule.SomeException dereference. Because all the modules had been reset, somemodule was None too.

Unfortunately the docs are completely devoid of this information, at least in the threading sections which you would actually reference. The best information I was able to find was this email to python-list a few years back, and a few other emails which don’t really put the issue front and center.

In the end the solution for us was simply to make them non-daemon threads, notice when the app is being shut down and join them to the main thread. Another possibility for us was to catch AttributeError in our thread wrapper class — which is what the author of the aforementioned email does — but that seems like papering over a real bug and a real error. Because of this misbehavior, daemon threads lose almost all of their appeal, but oddly I can’t find people really publicly saying “don’t use them” except in scattered emails. It seems like it’s underground information known only to the Python cabal. (There is no cabal.)

So, I am going to say it. When I went searching there weren’t any helpful hints in a Google search of “python daemon threads considered harmful”. So, I am staking claim to that phrase. People of The Future: You’re welcome.

Tags: , , ,

From the Safari 4 beta release:

* Full History Search, where users search through titles, web addresses and the complete text of recently viewed pages to easily return to sites they’ve seen before;

If you’ve been a Beagle user in the last 3 years this has been supported for Firefox and Epiphany users. But I wouldn’t mind seeing Firefox have this sort of indexing and search built-in either… the AwesomeBar was a great first step in that direction.

Tags: , , , , ,

giticular cancer

I haven’t been on d-d-l for months now, but when someone mentioned how comically entertaining the whole DVCS survey thread was, I just had to catch up.

From my cursory understanding, it seems like the data would be stored as bzr repositories and then new code would be developed to export those repositories over the git protocol, so that git users could use their own tools.

While it seems like a neat hack, and probably a worthwhile proof-of-concept, the idea that GNOME would switch to it seems completely insane to me. There are lots of reasons why, many addressed in the thread:

  • Why develop this code only for GNOME, instead of developing it with the support and blessing of upstream bzr and/or git? There the collective experience of these communities could guide and influence the development.
  • There is basically only one person developing this software, resulting in a critical piece of GNOME infrastructure with a bus factor of 1. This is very bad, and when you consider that the results of the survey strongly support Git, the vast majority of developers will be using it and would be inconvenienced if the system failed.
  • GNOME has a terrible track record of abandoned software — maybe it’s not actually any worse than other 10 year old large-scale open source projects — but it is very common. I don’t have any data to back this up, but I feel that in a lot of ways this is even more true for infrastructure that most developers never see.
  • The git-over-bzr option was never an option in the DVCS survey, but if it were it seems like it would have rated extremely lowly. There seems to be a vocal opposition to it in the thread.
  • This is an abstraction, and abstractions are always leaky. wxWindows kinda sucks because it can’t emulate all windowing systems equally. There is no way a git compatibility layer on top of a bzr repository will ever be as good as a native solution, just like git-on-svn isn’t as good as a pure git solution.
  • What happens when (not if, when) the git protocol changes in an incompatible way? Will we be at the mercy of someone to hack and fix the compatibility layer? Will the original author still be around and interested enough to do it, possibly years down the road?

The last point, combined with the abandonware point earlier, are what concern me the most. In the thread, David Zeuthen asked Olav Vitters:

Then what happens when a new version of git with a new feature, incompatible with the git-serve kludge, is released? Then we’re screwed, right? And who gets to pay? We do. We’re stuck with an old version of git. Us. The very same people who very clearly said “git”, not “bzr”.

Not the most politic way of saying it, but I think the point is valid. When I read that, I had deja vu, because I had just read this thread from early December about Bugzilla, initiated by Olav:

Subject: Reduced Bugzilla functionality for 6+ months — acceptable?

The GNOME Bugzilla is still using 2.20. Current stable upstream is at 3.2.
[...]
For that the proposal is that the following is not part of the initial
upgraded bgo:
* The points system
* index.cgi UI mods
* Making a new favicon
* The infomessages on show_bug.cgi
* Layout modifications for attachment table and the login box
* duplicates.cgi modifications
* Fixing the comment headers
* Patch and keyword emblems
* delete-keyword.pl, mass-reassign-bugs.pl, and year-end-stats.pl
* describeuser.cgi

In other words, upgrade the GNOME Bugzilla installation to a new version of the upstream software, and break all of GNOME’s current customizations. Is this not exactly what will happen eventually with the git kludge? I can foresee history repeating itself here. Bugzilla is pretty essential to GNOME, and degradation of service is undesirable. But a degraded, unavailable or fractured source control system is unconscionable.

Tags: , , , ,

On 20 December 2008 at 1:41 am, Brette and I welcomed our son Elliot into the world. Both mom and baby are doing very well, and we’ve loved the last several days getting to know each other.

[A photo by Joe Shaw]

This is his “black power” pose. Fight the man, little guy.

The previous day Brette, my mom and I were joking around that the baby would almost certainly come the following day — still a few days before his due date — during the snowstorm that was expected to drop up to 15 inches of snow on Boston. He didn’t disappoint. We found ourselves walking to the birth center about half a mile away in the 4 or 5 inches that had fallen at that point on nearly deserted roads during Friday rush hour, stopping briefly whenever Brette had a contraction.

[photo]

The birth went amazingly well and I am so proud of Brette. All of the nurses and midwives at the birth center were talking about what a wonderful job she did, and I couldn’t agree more.

A few things I wanted to mention:

If you prefer to give birth in a hospital, or want a pre-scheduled c-section, go for it. Do whatever is most comfortable and appropriate for you. But Brette and I wanted a natural childbirth without surgical intervention unless medically necessary, and for us the Cambridge Birth Center was the perfect place. Situated inside an old Victorian house, it sits across the street from the Cambridge Hospital. The rooms are homey and comforting. The only thing that annoyed us was the constant snow plowing going on just outside our window… but once things got down to business we weren’t paying attention to any of that. The nurses and midwives were so wonderful and accommodating. We were allowed to walk around, bring whatever food we wanted with us, got to sleep after the birth and go home the following afternoon. Just a great experience.

Ok, this is important: get a doula. I think I was as helpful and comforting as I could be for Brette, but look, I don’t have a uterus. I never have and probably never will. But a doula does. I don’t know physically what it’s like to give birth. A doula very well may have gone through it herself. But most importantly, they have training on ways to make the laboring woman more comfortable, and her entire job is to support and comfort. Ours was fantastic, and I can’t imagine going through the birth without her.

Also many thanks to my mom, who has been with us for the past week. She has helped us tremendously with keeping the house clean and orderly, making us food all the time, giving us a relief when we’ve been overwhelmed with E. at all hours, and sharing her experience with us.

Merry Christmas.

« Older entries § Newer entries »