We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Runtime error (BrokenPipeError) helpers.py line 11
When restarting i3 using `i3 restart`, error bar pops up with message `py3status: Runtime error (BrokenPipeError) helpers.py line 11. Please try to fix this and reload i3wm (Mod+Shift+R)`

Everything appears to be functioning and the bar still shows.

Running Ubuntu 16.04
py3status 3.1
python 3.5.2


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `py3status/__init__.py`
Content:
```
1 import locale
2 import sys
3 
4 from py3status.core import Py3statusWrapper
5 
6 try:
7     from setproctitle import setproctitle
8     setproctitle('py3status')
9 except ImportError:
10     pass
11 
12 
13 def main():
14     try:
15         locale.setlocale(locale.LC_ALL, '')
16     except locale.Error:
17         print('No locale available')
18         sys.exit(2)
19 
20     py3 = None
21     try:
22         py3 = Py3statusWrapper()
23         py3.setup()
24     except KeyboardInterrupt:
25         if py3:
26             py3.notify_user('Setup interrupted (KeyboardInterrupt).')
27         sys.exit(0)
28     except Exception as e:
29         if py3:
30             py3.report_exception('Setup error')
31         else:
32             # we cannot report this Exception
33             raise e
34         sys.exit(2)
35 
36     try:
37         py3.run()
38     except Exception:
39         py3.report_exception('Runtime error')
40         sys.exit(3)
41     except KeyboardInterrupt:
42         pass
43     finally:
44         py3.stop()
45         sys.exit(0)
46 
47 
48 if __name__ == '__main__':
49     main()
50
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/py3status/__init__.py b/py3status/__init__.py
--- a/py3status/__init__.py
+++ b/py3status/__init__.py
@@ -9,6 +9,13 @@
 except ImportError:
     pass
 
+try:
+    # python3
+    IOPipeError = BrokenPipeError
+except NameError:
+    # python2
+    IOPipeError = IOError
+
 
 def main():
     try:
@@ -21,9 +28,9 @@
     try:
         py3 = Py3statusWrapper()
         py3.setup()
-    except KeyboardInterrupt:
+    except (IOPipeError, KeyboardInterrupt):
         if py3:
-            py3.notify_user('Setup interrupted (KeyboardInterrupt).')
+            py3.notify_user('Setup interrupted')
         sys.exit(0)
     except Exception as e:
         if py3:
@@ -35,11 +42,11 @@
 
     try:
         py3.run()
+    except (IOPipeError, KeyboardInterrupt):
+        pass
     except Exception:
         py3.report_exception('Runtime error')
         sys.exit(3)
-    except KeyboardInterrupt:
-        pass
     finally:
         py3.stop()
         sys.exit(0)

{"golden_diff": "diff --git a/py3status/__init__.py b/py3status/__init__.py\n--- a/py3status/__init__.py\n+++ b/py3status/__init__.py\n@@ -9,6 +9,13 @@\n except ImportError:\n     pass\n \n+try:\n+    # python3\n+    IOPipeError = BrokenPipeError\n+except NameError:\n+    # python2\n+    IOPipeError = IOError\n+\n \n def main():\n     try:\n@@ -21,9 +28,9 @@\n     try:\n         py3 = Py3statusWrapper()\n         py3.setup()\n-    except KeyboardInterrupt:\n+    except (IOPipeError, KeyboardInterrupt):\n         if py3:\n-            py3.notify_user('Setup interrupted (KeyboardInterrupt).')\n+            py3.notify_user('Setup interrupted')\n         sys.exit(0)\n     except Exception as e:\n         if py3:\n@@ -35,11 +42,11 @@\n \n     try:\n         py3.run()\n+    except (IOPipeError, KeyboardInterrupt):\n+        pass\n     except Exception:\n         py3.report_exception('Runtime error')\n         sys.exit(3)\n-    except KeyboardInterrupt:\n-        pass\n     finally:\n         py3.stop()\n         sys.exit(0)\n", "issue": "Runtime error (BrokenPipeError) helpers.py line 11\nWhen restarting i3 using `i3 restart`, error bar pops up with message `py3status: Runtime error (BrokenPipeError) helpers.py line 11. Please try to fix this and reload i3wm (Mod+Shift+R)`\n\nEverything appears to be functioning and the bar still shows.\n\nRunning Ubuntu 16.04\npy3status 3.1\npython 3.5.2\n\n", "before_files": [{"content": "import locale\nimport sys\n\nfrom py3status.core import Py3statusWrapper\n\ntry:\n    from setproctitle import setproctitle\n    setproctitle('py3status')\nexcept ImportError:\n    pass\n\n\ndef main():\n    try:\n        locale.setlocale(locale.LC_ALL, '')\n    except locale.Error:\n        print('No locale available')\n        sys.exit(2)\n\n    py3 = None\n    try:\n        py3 = Py3statusWrapper()\n        py3.setup()\n    except KeyboardInterrupt:\n        if py3:\n            py3.notify_user('Setup interrupted (KeyboardInterrupt).')\n        sys.exit(0)\n    except Exception as e:\n        if py3:\n            py3.report_exception('Setup error')\n        else:\n            # we cannot report this Exception\n            raise e\n        sys.exit(2)\n\n    try:\n        py3.run()\n    except Exception:\n        py3.report_exception('Runtime error')\n        sys.exit(3)\n    except KeyboardInterrupt:\n        pass\n    finally:\n        py3.stop()\n        sys.exit(0)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "py3status/__init__.py"}], "after_files": [{"content": "import locale\nimport sys\n\nfrom py3status.core import Py3statusWrapper\n\ntry:\n    from setproctitle import setproctitle\n    setproctitle('py3status')\nexcept ImportError:\n    pass\n\ntry:\n    # python3\n    IOPipeError = BrokenPipeError\nexcept NameError:\n    # python2\n    IOPipeError = IOError\n\n\ndef main():\n    try:\n        locale.setlocale(locale.LC_ALL, '')\n    except locale.Error:\n        print('No locale available')\n        sys.exit(2)\n\n    py3 = None\n    try:\n        py3 = Py3statusWrapper()\n        py3.setup()\n    except (IOPipeError, KeyboardInterrupt):\n        if py3:\n            py3.notify_user('Setup interrupted')\n        sys.exit(0)\n    except Exception as e:\n        if py3:\n            py3.report_exception('Setup error')\n        else:\n            # we cannot report this Exception\n            raise e\n        sys.exit(2)\n\n    try:\n        py3.run()\n    except (IOPipeError, KeyboardInterrupt):\n        pass\n    except Exception:\n        py3.report_exception('Runtime error')\n        sys.exit(3)\n    finally:\n        py3.stop()\n        sys.exit(0)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "py3status/__init__.py"}]}