Example #1
0
File: mp.py Project: huazhz/gwpy
 def _read_single_file(fobj):
     try:
         return fobj, io_read(cls, fobj, *args, **kwargs)
     # pylint: disable=broad-except,redefine-in-handler
     except Exception as exc:
         if nproc == 1:
             raise
         if isinstance(exc, SAXException):  # SAXExceptions don't pickle
             return fobj, exc.getException()  # pylint: disable=no-member
         return fobj, exc
Example #2
0
File: mp.py Project: stefco/gwpy
 def _read_single_file(fobj):
     try:
         return fobj, io_read(cls, fobj, *args, **kwargs)
     # pylint: disable=broad-except,redefine-in-handler
     except Exception as exc:
         if nproc == 1:
             raise
         if isinstance(exc, SAXException):  # SAXExceptions don't pickle
             return fobj, exc.getException()  # pylint: disable=no-member
         return fobj, exc
Example #3
0
File: mp.py Project: jumbokh/gwpy
 def _read_single_file(f):
     try:
         return f, io_read(cls, f, *args, **kwargs)
     except Exception as e:
         if nproc == 1:
             raise
         elif isinstance(e, SAXException):  # SAXExceptions don't pickle
             return f, e.getException()
         else:
             return f, e
Example #4
0
File: cache.py Project: stefco/gwpy
 def _read_segment(segment):
     try:
         if segment[0] is None:
             pseg = segment
             subcache = cache
         else:
             pseg = segment.protract(overlap) & cspan  # processing segment
             subcache = cache.sieve(segment=pseg)
         data = io_read(cls, subcache, channel, start=pseg[0], end=pseg[1],
                        **kwargs)
         if resample:
             data = data.resample(resample)
         if overlap:  # crop out the overlap introduced for resampling
             return data.crop(*segment)
         return data
     except Exception as exc:  # pylint: disable=broad-except
         if nproc == 1:  # raise now
             raise
         return exc  # will be raised after multiprocessing closes
Example #5
0
File: mp.py Project: rngeorge/gwpy
def _read_single_file(bundle):
    """Reads a single file and returns the output

    This is designed only to be passed to
    :func:`gwpy.utils.mp.multiprocess_with_queues`

    Returns
    -------
    f, output :
        the input file (object) that was (attempted to be) read, and
        the result of the read operation, which may be an exception
        object.
    """
    fobj, cls, nproc, args, kwargs = bundle
    try:
        return fobj, io_read(cls, fobj, *args, **kwargs)
    # pylint: disable=broad-except,redefine-in-handler
    except Exception as exc:
        if nproc == 1:
            raise
        if isinstance(exc, SAXException):  # SAXExceptions don't pickle
            return fobj, exc.getException()  # pylint: disable=no-member
        return fobj, exc
Example #6
0
 def _read_segment(segment):
     try:
         if segment[0] is None:
             pseg = segment
             subcache = cache
         else:
             pseg = segment.protract(overlap) & cspan  # processing segment
             subcache = cache.sieve(segment=pseg)
         data = io_read(cls,
                        subcache,
                        channel,
                        start=pseg[0],
                        end=pseg[1],
                        **kwargs)
         if resample:
             data = data.resample(resample)
         if overlap:  # crop out the overlap introduced for resampling
             return data.crop(*segment)
         return data
     except Exception as exc:  # pylint: disable=broad-except
         if nproc == 1:  # raise now
             raise
         return exc  # will be raised after multiprocessing closes