Repository: spyder-ide/spyder

Issue:
BrokenPipeError when trying to connect to the Pydoc server
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Went into preferences-> appearance to incresae font size. changed from 9 to 10, pressed apply. ok. changed from 10 to 11, pressed apply. got this issue reporter screen

### Traceback
```python-traceback
  File "/usr/lib64/python3.8/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib64/python3.8/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib64/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib64/python3.8/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/usr/lib64/python3.8/http/server.py", line 415, in handle_one_request
    method()
  File "/usr/lib/python3.8/site-packages/spyder/plugins/onlinehelp/pydoc_patch.py", line 910, in do_GET
    self.wfile.write(self.urlhandler(
  File "/usr/lib64/python3.8/socketserver.py", line 799, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
```

## Versions

* Spyder version: 4.1.4 
* Python version: 3.8.3
* Qt version: 5.15.0
* PyQt5 version: 5.13.2
* Operating System: Linux 5.7.9-1-default

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.4.1 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.16.1 (OK)
jedi >=0.17.1                  :  0.17.1 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
parso >=0.7.0                  :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.5.3 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.6.0 (OK)
qtconsole >=4.6.0              :  4.7.5 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
sphinx >=0.6.6                 :  3.0.4 (OK)
spyder_kernels >=1.9.2;<1.10.0 :  1.9.2 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  0.29.21 (OK)
matplotlib >=2.0.0             :  3.2.2 (OK)
numpy >=1.7                    :  1.18.4 (OK)
pandas >=0.13.1                :  1.0.5 (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  1.6 (OK)

# Spyder plugins:
spyder_line_profiler           :  0.2.1 (OK)
spyder_memory_profiler         :  0.2.1 (OK)
spyder_notebook                :  0.2.3 (OK)
spyder_terminal                :  0.3.2 (OK)
```



Discussion:
Hi @robwarm,
I'm not able to reproduce this, can you please upload a gif with the error?
Are you changing `rich text` or `plain text` in the appearance pane and do you have something open in the `online help` pane?
Hi @steff456 ,
thanks for the response. I can reproduce the behaviour changing the plain text twice (fe. increase by 1, apply increase by 1, apply). The message appears after the text in the main window is updated to the new size. Changing the rich text size works fine.
Regarding the help plane... I don't pay attention to what's in there, but the error stil appears if I close that pane before changing the setting.
Let me know, if I can do more to help.
![Screenshot from 2020-07-28 20-28-28](https://user-images.githubusercontent.com/4659535/88706779-9ef92a00-d111-11ea-806f-c72e1c84660d.png)

@robwarm, thanks for reporting! This looks like a legitimate error, but not directly related to applying a font size change.

We'll fix it in our next version, to be released in a couple of months.

Resolving patch:
diff --git a/spyder/plugins/onlinehelp/pydoc_patch.py b/spyder/plugins/onlinehelp/pydoc_patch.py
--- a/spyder/plugins/onlinehelp/pydoc_patch.py
+++ b/spyder/plugins/onlinehelp/pydoc_patch.py
@@ -914,6 +914,11 @@ def do_GET(self):
                 # for example when the client stops the load of the previously
                 # requested page. See spyder-ide/spyder#10755
                 pass
+            except BrokenPipeError:
+                # Needed to handle permission error when trying to open a port
+                # for the web server of the online help.
+                # See spyder-ide/spyder#13388
+                pass
 
         def log_message(self, *args):
             # Don't log messages.


Test patch: