lightning/pytorch_lightning/utils/debugging.py

15 lines
366 B
Python
Raw Normal View History

2019-07-24 14:34:21 +00:00
import pdb
import sys
class ForkedPdb(pdb.Pdb):
"""A Pdb subclass that may be used
from a forked multiprocessing child
"""
def interaction(self, *args, **kwargs):
_stdin = sys.stdin
try:
sys.stdin = open('/dev/stdin')
pdb.Pdb.interaction(self, *args, **kwargs)
finally:
sys.stdin = _stdin