Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Wed, 30 Jul 2008

Beware Python 2.4's subprocess module

The subprocess module in Python 2.4 has a race condition. If you're doing process.communicate() on more than one pipe, on a Unix-like system you may end up getting an exception (4, 'Interrupted system call') when the child process terminates, if the SIGCHLD signal arrives at an inopportune moment.

This bug appears to be fixed in Python 2.5.2, where all calls to select, read and write are wrapped in a while looks and ignore EINTR errors.

Maybe this blog post will save someone else the hour needed to study strace logs trying to figure this out.

Update: It's not fixed in upstream Python. Ubuntu patched it a year ago for python2.5, but not for python2.4. Upstream knows about the patch, but so far only a partial fix (EINTR guard around select, but not around read/write) has made it into svn trunk (but not the 2.5 maintenance branch, yet, and I'm not even thinking about 2.4).

posted at 15:16 | tags: | permanent link to this entry | 0 comments

Sat, 26 Jul 2008

Eazysvn 1.8.0, restview 1.0.0

Today was a release day for me.

I released eazysvn 1.8.0, the helpful syntactic sugar wrapper that makes using Subversion branches almost not painful. This is the first release with full on-line documentation (at last).

I also bumped the version number of restview, my ReStructuredText viewer, to a solid 1.0.0. I've been using it for years now without problems, which was not immediately apparent from the old version number (a modest 0.0.5).

Before that I made my first ever bugfix releases of a couple of Zope 3 packages (zope.component 3.5.1 and zope.app.testing 3.4.3). Blame me if anything is wrong with them. Kudos to Philipp von Weitershausen for his release process documentation.

posted at 03:01 | tags: | permanent link to this entry | 0 comments

Fri, 25 Jul 2008

D-bus frustration

So, you hear that your media player supports remote control over D-Bus. That's great, isn't it?

So, you're lying on a couch, listening to music and reading a book on your N810. Suddenly a song you don't like starts playing. Do you

A. Stand up, walk to the PC, click the "Next song" button with your mouse,

or

B. Open Terminal on your N810, ssh into your desktop and run banshee-1 --next?

If you chose option B, you lose:

mg@mg-desktop:~$ banshee-1 --next
[Warn  00:43:59.080] DBus support could not be started. Disabling for this session.
[Info  00:43:59.101] Running Banshee 1.0.0

(Nereid:9174): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.

(Nereid:9174): Gtk-WARNING **: cannot open display: 

You can't access your D-Bus session from a different login session. This means, among other things, that I cannot ask gnome-power-manager to suspend my laptop that I left at work if I'm trying to run gnome-power-cmd.sh suspend over an SSH session.

Dear lazyweb, what's the fix?

P.S. I apologise for the impertinence of asking dear lazyweb a question on a blog that has no comments facility, but I somehow cannot bring myself to trust Pyblosxom's comment plugins in today's spam-filled world without an in-depth evaluation for which I don't have the time and energy. At least there's a mailto link clearly labeled "send feedback" below each blog entry.

Update: Steve Holden suggested using screen, which works, but only if I have the foresight to start a screen session on the desktop before I walk away. I can then reattach to the running screen session with screen -x and run banshee-1 --next inside.

Ross Burton says that setting DISPLAY=:0 ought to help D-Bus find the existing session, but only if I have the very latest and greatest D-Bus (1.2.1), which I don't have. With D-Bus 1.1.20 in Hardy, all I get by setting $DISPLAY is Banshee opening a second player instance.

Update #2: Lee Harr suggests fishing out the DBUS_SESSION_BUS_ADDRESS environment variable from ~/.dbus/session-bus/*.

Update #3: Kees Cook also has a solution.

posted at 01:00 | tags: | permanent link to this entry | 0 comments

Fri, 11 Jul 2008

EuroPython 2008 sprints, day 2

Hacked on XDot, which uses PyGtk/Cairo and the xdot intermediate format and thus sidesteps the limitations I encoutered working on dotviewer. My changes are in a Git branch created with git-svn. Get it here:

git clone http://mg.pov.lt/xdot-mg.git

Try it out

cd xdot-mg
./xdot.py sample2.dot

See the changes

gitk --all

Overview:

I must admit that git is nicer than bzr to work with, but a bit of a pain when you want to publish or share your changes.

I will not be sprinting tomorrow.

posted at 20:11 | tags: | permanent link to this entry | 0 comments

EuroPython 2008 sprints, day 1

Hacked on dotviewer that was developed for PyPy but is now a standalone tool. My changes are in a Bazaar branch created with bzr-svn. Get it here:

bzr get http://mg.pov.lt/dotviewer-mg/

Try it out

cd dotviewer-mg
./dotviewer.py sample2.dot

See the changes

bzr vis

Overview:

Then I hit some limitations: it's either impossible or very hard to get pretty anti-aliased output or smooth text scaling with Pygame. It's impossible to support all dot features using the plain intermediate format.

posted at 20:01 | tags: | permanent link to this entry | 0 comments

EuroPython 2008 highlights

Highlights from EuroPython 2008:

Won a Wing IDE licence in the raffle. Not going to use it myself (vim is the best, and I should publish my plugins). Also, I avoid closed-source software when I can.

posted at 19:39 | tags: | permanent link to this entry | 0 comments