Montellese / mediaimporter.emby

Media importer add-on for Kodi to import items from Emby servers into Kodi
GNU General Public License v2.0
12 stars 3 forks source link

Rare socket timout exception #21

Closed sualfred closed 4 years ago

sualfred commented 4 years ago

Had this exception again today but wasn't able to reproduce it so no debug log, sorry. But afair I already talked to you about it some weeks ago. It was happening right after starting Kodi and while it was loading the home screen.

Just dropping it here to keep it in mind.

2020-04-13 15:43:41.384 T:27584   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'socket.timeout'>
                                            Error Contents: timed out
                                            Traceback (most recent call last):
                                              File "E:\Kodi\Kodi Media Import\portable_data\addons\mediaimporter.emby\discovery.py", line 16, in <module>
                                                DiscoveryService()
                                              File "E:\Kodi\Kodi Media Import\portable_data\addons\mediaimporter.emby\lib\discovery.py", line 35, in __init__
                                                self._start()
                                              File "E:\Kodi\Kodi Media Import\portable_data\addons\mediaimporter.emby\lib\discovery.py", line 108, in _start
                                                self._discover()
                                              File "E:\Kodi\Kodi Media Import\portable_data\addons\mediaimporter.emby\lib\discovery.py", line 45, in _discover
                                                (data, _) = self._sock.recvfrom(1024)
                                            socket.timeout: timed out
                                            -->End of Python script error report<--
2020-04-13 15:43:41.579 T:8976 WARNING: CMediaImportManager: source registration task for "PCFRED: xxxxxxxxxx:" (upnp://d04ada49-cb13-4f5e-b7f5-253437a6ccda) failed
Montellese commented 4 years ago

Hm I'm not sure how this can happen. The referenced code looks like this:

try:
    self._sock.settimeout(DiscoveryService.DiscoveryTimeoutS)
    (data, _) = self._sock.recvfrom(1024)
except socket.timeout:
    return

so it explicitely handles socket.timeout errors from socket.recvfrom(). I don't know how it could still end up being propagated to Kodi's default error handler.

sualfred commented 4 years ago

No idea. With a simple raise socket.timeout for testing it is not throwing an Exception. I also cannot reproduce it or don't know how. Got this issue 2-3 times since I'm testing your project over the last couple of months.

Montellese commented 4 years ago

I'm guessing this is also related to https://github.com/Montellese/mediaimporter.emby/issues/18#issuecomment-622668661 right? Should we close it since it's a general Kodi issue?

sualfred commented 4 years ago

I assume, yes.

Funny thing is, that I never ever faced any thrown exception again since I've changed the changed the exception in script.module.urllib3 to except: