Handle IOError: [Errno 32] Broken pipe
Will happen if piping through a pager like less, that closes stdout before everything has been printed. Related: #47
This commit is contained in:
parent
2ba435126d
commit
5ca090668f
16
pubs/pubs
16
pubs/pubs
@ -1,5 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
from pubs import pubs_cmd
|
||||
pubs_cmd.execute()
|
||||
|
||||
try:
|
||||
pubs_cmd.execute()
|
||||
except IOError:
|
||||
# stdout or stderr has been closed, cleaning up
|
||||
try:
|
||||
sys.stdout.close()
|
||||
except IOError:
|
||||
pass
|
||||
try:
|
||||
sys.stderr.close()
|
||||
except IOError:
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user