[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Trapping condor_hold in Python scripts on Windows

Windows doesn't actually have signals, so HTCondor simulates them when talking to it's own daemons by sending socket messages - so when the starter log on windows says 'Got SIGTERM' it's lying.
what it really got was a daemon command message.

We can't do the same thing for jobs though, for windows jobs we send a WM_CLOSE message to the job. So you want to somehow catch the WM_CLOSE in python and treat it like a SIGTERM.

I would imagine that this would involve somehow getting python to register a ConsoleControlHandler callback


On 8/7/2015 2:16 PM, Ben Cotton wrote:
Has anyone had any luck trapping when a Python script is placed on
hold on Windows? My proof-of-concept script below works on Linux, but
not on Windows, despite the fact that the starterlog suggests that it

08/07/15 14:53:10 (pid:7952) Got SIGTERM. Performing graceful shutdown.

import os
import signal
import sys
import time

def cleanShutdown(signal, frame):
     '''A method to handle shutdowns. This is necessary to prevent the agent from
     hanging on a HTCondor shutdown, since the shutdown script sends SIGQUIT
     instead of SIGTERM.'''

     print 'Received signal %i, shutting down server' % signal

# Capture SIGINT and SIGQUIT
if os.name != 'nt':