##// END OF EJS Templates
regexp group in BatchLauncher, no Condor -verbose...
regexp group in BatchLauncher, no Condor -verbose Previously I used condor_submit -verbose so that I could pull the job id from the first line. However, when submitting many jobs it's silly to have to search through some many lines of output. Now we have a regexp for Condor that matches on the non-verbose output. Here the job_id is on the end of the output, so using grouping in our job_id_regexp becomes very useful. To account for this I have added a job_id_regexp_group property to the BatchLauncher and it's subclasses. The default of 0 means the whole regexp is matched - however now an integer can be passed in here to instead select a subgroup of the expression (see CondorLauncher and the mechanism will be clear).

File last commit:

r9372:37f32253
r10991:ee0bd57f
Show More
heartbeat.py
57 lines | 2.0 KiB | text/x-python | PythonLexer
Brian Granger
Added heartbeat support.
r2910 """The client and server for a basic ping-pong style heartbeat.
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
Added heartbeat support.
r2910 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
MinRK
enable IPC transport for kernels...
r7321 import os
MinRK
specify heartbeat port at construction, not in run...
r4500 import socket
Brian Granger
Added heartbeat support.
r2910 import sys
from threading import Thread
import zmq
MinRK
Possible fix for GH-169
r3144 from IPython.utils.localinterfaces import LOCALHOST
Brian Granger
Added heartbeat support.
r2910 #-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class Heartbeat(Thread):
"A simple ping-pong style heartbeat that runs in a thread."
MinRK
enable IPC transport for kernels...
r7321 def __init__(self, context, addr=('tcp', LOCALHOST, 0)):
Brian Granger
Added heartbeat support.
r2910 Thread.__init__(self)
self.context = context
MinRK
enable IPC transport for kernels...
r7321 self.transport, self.ip, self.port = addr
MinRK
specify heartbeat port at construction, not in run...
r4500 if self.port == 0:
MinRK
enable IPC transport for kernels...
r7321 if addr[0] == 'tcp':
s = socket.socket()
# '*' means all interfaces to 0MQ, which is '' to socket.socket
s.bind(('' if self.ip == '*' else self.ip, 0))
self.port = s.getsockname()[1]
s.close()
elif addr[0] == 'ipc':
MinRK
fix default heartbeat location when transport is ipc
r9176 self.port = 1
while os.path.exists("%s-%s" % (self.ip, self.port)):
MinRK
enable IPC transport for kernels...
r7321 self.port = self.port + 1
else:
raise ValueError("Unrecognized zmq transport: %s" % addr[0])
MinRK
fix --ip='*' argument in various apps...
r5170 self.addr = (self.ip, self.port)
Brian Granger
Added heartbeat support.
r2910 self.daemon = True
def run(self):
self.socket = self.context.socket(zmq.REP)
MinRK
enable IPC transport for kernels...
r7321 c = ':' if self.transport == 'tcp' else '-'
self.socket.bind('%s://%s' % (self.transport, self.ip) + c + str(self.port))
Brian Granger
Added heartbeat support.
r2910 zmq.device(zmq.FORWARDER, self.socket, self.socket)