Versions Compared

    Key

    • This line was added.
    • This line was removed.
    • Formatting was changed.
    Comment: Published by Scroll Versions from this space and version 7.0-2

    ...

    In this example, there are presumably 4 implementation files in the callback directory, logFailuresToDB.py, mail-status.qcb, submitted.py, and checkWork.pl, that have the implementation code in them.

    Note
    titleUse subprocess.Popen in callbacks

    If you ever need to run an external script in a callback, we recommend the use of subprocess.Popen() to run the external script inside the callback. This returns immediately and allows the callback to continue running, rather than blocking and waiting for the external script to complete; otherwise the supervisor process is tied up for the duration of the external script's execution.

    Do not use os.system() to run the external script, as this call will block until the external script exits. When a large number of callbacks tie up supervisor processes at the same time, your supervisor performance will suffer.

    Warning
    titleNever use sys.exit() in a callback

    Do not call sys.exit() at the end of the callback code, this kills the calling supervisor process.

    Code Block
    titlesubmitted.py
    languagepy
    #!/usr/bin/env python
    
    import sys
    import qb
    import traceback
    
    fh = open('/tmp/univeral_callback_test', 'a')
    try:
        # ==================================================
        #  === NOTE: ===
        #  the qb.jobinfo() in callbacks is not the
        #  same as the one in the external python API 
        # ==================================================
        job = qb.jobinfo("-id", qb.jobid())[0]
        fh.write('submitted %(id)s: %(name)s\n' % job)
    except:
        fh.write(traceback.format_exc())
    fh.close()
    
    sys.exit(0) 

     

    Include+
    scrollPageId405BE23F014B092BED873659461D31E3
    scrollEditorDisplayTitle_universal_cb_vs_flightchecks
    scrollEditorUrlhttp://docs.pipelinefx.com/display/QUBE/._universal_cb_vs_flightchecks+v6.6-3

    ...