Saturday, January 06, 2007

Being TOO Careful

A program at work gave me a bit of trouble these past two work weeks (the holiday break interrupted the debugging).

It's a process manager for the product, allowing the user to start and stop the various parts of the system, and it also monitors the processes to restart them if they fail. Basically, all the same stuff initd does under Unix, but for the specific system applications.

Now, for some reason, it does not keep its list of child processes in memory, but uses the 'ps' function to get them, filtering the output to eliminate things using the executable name in other ways. However, it expects the executable to be the first thin in the command line section of the output.

That's it - no provision for an interpreted script at all. And my most recent work is a rapid-prototype server in Python. So it can't be controlled from the manager. And it's buried in old, barely managed code, so I'm reluctant to dive into that swamp without managerial mandate.

(To be fair, this is one of the oldest parts of the system, written over a decade ago, so it was probably not a high probability that interpreted languages would be used in the system at that time. But it still was a real pain to have this float out of the miasma of reported bugs coming from the 3 sets of testing staff.)

Fortunately, Python's embedding feature saved me here; I was able to throw together a quick C++ wrapper that would call the Python script, waiting for it to exit. So now I get the monitor to start and stop it cleanly, but keep the useful parts in Python.

There is a plan to move the code more to C++, but the need to do several things that we have no C++ libraries for will keep some Python in the mix.

[Later]
Mea Culpa, Readers! I forgot to relate the moral of this story, in all my bitching and moaning.

The Lesson: When filtering results, the Software Ninja makes sure the filtering code is a) separated into an independent function, and b) make the filtering criteria very clear, so that the next developer to work on the code can change the filtering if necessary, and will understand what is being filtered out.



Technorati Tags --
, , ,
HTTP

No comments: