Browse Source

Set up default SIGPIPE handler

This lets you do something like "nilmtool extract | head" without
triggering backtraces.
tags/nilmdb-1.5.1^0
Jim Paris 8 years ago
parent
commit
99a4228285
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      nilmdb/cmdline/cmdline.py

+ 8
- 0
nilmdb/cmdline/cmdline.py View File

@@ -10,6 +10,7 @@ import sys
import os
import argparse
from argparse import ArgumentDefaultsHelpFormatter as def_form
import signal

try: # pragma: no cover
import argcomplete
@@ -126,6 +127,13 @@ class Cmdline(object):
sys.exit(-1)

def run(self):
# Set SIGPIPE to its default handler -- we don't need Python
# to catch it for us.
try:
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
except ValueError: # pragma: no cover
pass

# Clear cached timezone, so that we can pick up timezone changes
# while running this from the test suite.
datetime_tz._localtz = None


Loading…
Cancel
Save