Wandering Thoughts archives

2006-08-30

A problem with debugging threaded Python programs

I have a heavily threaded Python program that dies every now and then with a mysterious exception (that as far as I can see just shouldn't happen, which means that I don't completely understand my code).

My off and on attempts to debug this have pointed out a frustrating problem in Python's (lack of) support for debugging threaded Python programs: there's no such thing as a global exception, something that will freeze, backtrace, and terminate all threads when an error occurs. Instead, exceptions only capture the state of the thread they happen in, and only kill it.

(My program goes down because the exception is happening in the main thread, and all the other threads are short-lived.)

The irony is that Python's single-threaded bytecode interpreter would make this relatively easy to do. You could guarantee that the next bytecode-level action every other thread did was to throw an exception, and you'd be capturing pretty close to the exact state when the starting exception was created. (With some more work, you could make it an exact capture; just keep track of the last bytecode executed and generate the exception against it.)

python/ThreadDebuggingProblem written at 23:40:02; Add Comment

How to lose readers of your syndication feed

It's pretty simple:

  • change your syndication feed URL
  • but don't remove or redirect the old feed, just stop updating it
  • and don't put up an entry about it (visible in the old feed).

Readers who are not especially attentive may not notice for weeks, only vaguely wondering if you've taken a vacation or something. Especially if they read a fair amount of feeds and are behind in their reading.

As far as I've gathered, most feed readers are perfectly willing to have the feed format change out from under them, so there's no real reason not to redirect old feed URLs to the new canonical one. If you have mass quantities of automatically generated feeds this may be a bit challenging to do, but most things with feeds just have one or two.

(In theory a permanent redirection should even cause feed readers to update their internal memory of where to get the feed from, but I'm willing to bet that that's mostly honored in the breach.)

In my case, the only way I noticed was that someone else linked to an entry I hadn't seen on the blog in question. When I clicked through to read it, assuming it was an old one, I happened to notice that it was actually a recent entry, and that set me to wondering why I hadn't seen it in the feed.

tech/LosingFeedReaders written at 09:33:34; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.