[wmii] Re: wmiirc Locking Up

From: Jeremy Hankins <nowan_AT_nowan.org>
Date: Wed, 14 Jun 2006 11:23:24 -0400

"Anselm R. Garbe" <garbeam_AT_wmii.de> writes:

> Doesn't sound to be a wmiir-related problem but maybe a
> python-thread-related issue with forked processes in my eyes (however
> I have no clue about python). Only reading from /event will block
> wmiir from exiting until the 9P server closes or wmiirc is exit (which
> runs wmiir read /event).

Hrm. Quite possible, of course -- I'm new to multithreaded programming
in general, to say nothing of doing it in python in particular. But the
function calling wmiir is quite straightforward. If there's anyone here
who knows python and might be able to offer suggestions, I'd welcome
them. Popen and PIPE are from subprocess (Python 2.4). The wmiir
process was definitely hanging around, though. I could see it in ps,
and confirm it via the exception when I eventually killed it. But as I
said, so far no problems with the lock in place.

def wmiir(self, args, inp = None):
    """Run wmiir. Send any input, return any output.
    """
    self.wmiir_lock.acquire()
    p = Popen(("wmiir",) + args,
              stdin = PIPE,
              stdout = PIPE,
              stderr = PIPE)
    out = p.communicate(inp)
    self.wmiir_lock.release()

    if p.returncode != 0:
        raise wmiiError("Error running wmiir: args: %s, return code: %d" % (repr(args), p.returncode))

    return(out)

-- 
Jeremy Hankins <nowan_AT_nowan.org>
PGP fingerprint: 748F 4D16 538E 75D6 8333  9E10 D212 B5ED 37D0 0A03
Received on Wed Jun 14 2006 - 17:23:32 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:09:23 UTC