1 """!Contains setup(), which initializes the produtil package.
3 This module contains the setup() function that should be called once
4 by every Python process started, immediately after Python starts."""
10 import logging, threading
14 def setup(ignore_hup=False,dbnalert_logger=None,jobname=None,cluster=None,
15 send_dbn=
None,thread_logger=
False,thread_stack=2**24,**kwargs):
16 """!Initializes the produtil package. Calls the module
17 initialization functions for all other modules in the produtil
22 1. Installs signal handlers that will cleanly abort the process.
23 2. Sets up logging to the jlogfile, if $jlogfile is in the environment.
24 3. Sets up logging to stdout and stderr.
25 4. Sets up the produtil.dbnalert module so DBNAlert objects will
27 5. Sets the produtil.cluster's idea of what cluster it is on. If no
28 cluster is specified, the produtil.cluster is instructed to guess.
30 This is a wrapper around the produtil.sigsafety, and produtil.log,
31 and other module initializers. Note that one could call each
32 module's initialization functions directly instead. However, one
33 would have to keep up with changes to the produtil package during
34 upgrades in order to do that.
36 @param ignore_hup if True, this program will ignore SIGHUP. Use
37 this for UNIX daemon processes. Turned off (False) by default,
38 causing SIGHUP to be a terminal signal.
39 @param dbnalert_logger sent to dbnalert.init_module's logger argument
40 to initialize the logging domain for informational messages
42 @param jobname dbn_alert job string
43 @param cluster if specified and not None, sent to produtil.cluster's
44 set_cluster. Otherwise, produtil.cluster.where() is called to
45 guess the cluster, or set suitable defaults.
46 @param send_dbn should dbn alerts be sent?
47 @param thread_logger if True, log messages will include thread name.
48 @param thread_stack passed to threading.stack_size(); the stack size in
49 bytes for new threads. The default is 2**24, which is 16 MB.
50 See the threading module for details. Set to None to disable
51 changing of the threading stack size.
52 @param kwargs all other keyword args sent to produtil.log.configureLogging()"""
58 if thread_stack
is not None:
59 threading.stack_size(thread_stack)
63 if jobname
is not None:
76 if cluster
is not None:
def install_handlers
Installs signal handlers that will raise exceptions.
Sets up signal handlers to ensure a clean exit.
def where()
Guesses what cluster the program is running on, and if it cannot, returns a cluster named "noname" wi...
def setup(ignore_hup=False, dbnalert_logger=None, jobname=None, cluster=None, send_dbn=None, thread_logger=False, thread_stack=2 **24, kwargs)
Initializes the produtil package.
Provides information about the cluster on which this job is running.
This module runs the NCO dbn_alert program, or logs dbn_alert messages if run with dbn alerts disable...
def set_default_name(default_name)
Set default for all job names.
def configureLogging
Configures log output to stderr, stdout and the jlogfile.
def set_cluster(there)
Sets the current cluster (module-level "here" variable) to the given value.
Provides information about the batch system.
def init_module
Call to initialize this module.