"""
WSGI config for testsite project.

This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.

Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.

"""
import os, signal

#pylint: disable=invalid-name

def save_coverage(*args, **kwargs):
    #pylint:disable=unused-argument
    sys.stderr.write("saving coverage\n")
    cov.stop()
    cov.save()

if os.getenv('DJANGO_COVERAGE'):
    import atexit, sys
    import coverage
    cov = coverage.coverage(data_file=os.path.join(os.getenv('DJANGO_COVERAGE'),
        ".coverage.%d" % os.getpid()))
    cov.start()
    atexit.register(save_coverage)
    try:
        signal.signal(signal.SIGTERM, save_coverage)
    except ValueError as e:
        # trapping signals does not work with manage
        # trying to do so fails with
        # ValueError: signal only works in main thread
        pass

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsite.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
#pylint: disable=invalid-name
application = get_wsgi_application()

[((26, 3, 26, 31), 'os.getenv', 'os.getenv', ({(26, 13, 26, 30): '"""DJANGO_COVERAGE"""'}, {}), "('DJANGO_COVERAGE')", False, 'import os, signal\n'), ((41, 0, 41, 68), 'os.environ.setdefault', 'os.environ.setdefault', ({(41, 22, 41, 46): '"""DJANGO_SETTINGS_MODULE"""', (41, 48, 41, 67): '"""testsite.settings"""'}, {}), "('DJANGO_SETTINGS_MODULE', 'testsite.settings')", False, 'import os, signal\n'), ((48, 14, 48, 36), 'django.core.wsgi.get_wsgi_application', 'get_wsgi_application', ({}, {}), '()', False, 'from django.core.wsgi import get_wsgi_application\n'), ((22, 4, 22, 41), 'sys.stderr.write', 'sys.stderr.write', ({(22, 21, 22, 40): '"""saving coverage\n"""'}, {}), "('saving coverage\\n')", False, 'import atexit, sys\n'), ((32, 4, 32, 34), 'atexit.register', 'atexit.register', ({(32, 20, 32, 33): 'save_coverage'}, {}), '(save_coverage)', False, 'import atexit, sys\n'), ((34, 8, 34, 52), 'signal.signal', 'signal.signal', ({(34, 22, 34, 36): 'signal.SIGTERM', (34, 38, 34, 51): 'save_coverage'}, {}), '(signal.SIGTERM, save_coverage)', False, 'import os, signal\n'), ((29, 51, 29, 79), 'os.getenv', 'os.getenv', ({(29, 61, 29, 78): '"""DJANGO_COVERAGE"""'}, {}), "('DJANGO_COVERAGE')", False, 'import os, signal\n'), ((30, 25, 30, 36), 'os.getpid', 'os.getpid', ({}, {}), '()', False, 'import os, signal\n')]