On 20/06/11 04:51, Paul Wise wrote:
> […] which servers to restart when upgrading a
> python library for security updates. Any thoughts?


Your Python process knows what it's got imported by looking as
sys.modules. Could your trigger prod it with some signal to tell it to
dump filenames to some well-known location? It could then check that
list for updated files.

Something like:

"""
import os
import signal
import sys
import time

def dump_modules(signum, frame):
    filenames = [m.__file__ for m in sys.modules.itervalues() if
hasattr(m, '__file__')]
    with open('module_filenames.txt', 'w') as f:
        for filename in filenames:
            filename = os.path.abspath(filename)
            f.write(filename + '\n')

signal.signal(signal.SIGUSR1, dump_modules)

while True:
    time.sleep(1)
"""


Yours,

Alex

[NB: I know very little about the Debian/packaging-side of things. I
hope to rectify this soon!]


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4dff2ddf.2010...@alexdutton.co.uk

Reply via email to