wolf

You are currently browsing articles tagged wolf.

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: , , , ,

Market got you down?

Nosedive

Feel like the Google Finance favicon doesn’t accurately reflect the year you’ve had? Well, I can help! This Greasemonkey script will correctly replace the favicon with one more representative of the ongoing collapse of the entire financial system.

Much better

Enjoy it while you can! Pretty soon you’ll have to sell your computer and move to the poor house.

Update: Unlike the lame duck administration, I welcome oversight on my activities! Aaron suggests that the icon should be red instead of green. I agree with him. The red represents two things: (1) the financial value of your dwindling retirement nest egg and (2) the rage you will feel when a callous loan servicer refuses to renegotiate the terms of your mortgage and forecloses on your home. At least you could probably move back in with your parents.

The new change is now live.

Tags: , , , , ,

Karl,

There is no code for the Association Browser, unless that’s changed in the year since I’ve been gone. I remember the idea was first devised during a series of brainstorming meetings among the desktop hackers, probably in 2004, and Jimmac (I think? Maybe Garrett) created this first-pass mockup one day:

Association browser mockup

There may have been an internal wiki page about it, but certainly no code.

The idea with the association browser was that you’d have a “focal object” (in this case, “Brand Grub”) and you’d see items directly related to that object in a way that was appropriate for that data. This was somewhat similar to how Dashboard worked — each piece of data looked different and specific to its type: emails looked different than documents and addressbook contacts, for example. But unlike Dashboard, this would be a fully-fledged application you could use to navigate your data. If you wanted to shift your focal object, say from “Brand Grub” to “Bilbo Baggins”, you could do that easily… I think we called that “rotating”.

The purpose of showing this in my old GUADEC talk was to illustrate the kinds of interesting applications people could build on top of Beagle beyond the obvious and boring all-encompassing search tools. Unfortunately I don’t think that’s happened. From my perspective, both Beagle and Tracker ended up focusing way too much on the backend (storage and retrieval of metadata just aren’t that interesting to most people) and not enough on making users’ lives easier.

So there you have it. The “code” for the association browser. Next time, feel free to email me about it first.

Tags: , ,

« Older entries