Closed fe31nz closed 2 years ago
MythTV/utility/other.py : class deadlinesocket
If there is no data available from the socket, the method 'deadlinesocket.dlexpect()' should raise the same error as the method 'deadlinesocket.dlrecv()':
raise MythError(MythError.SOCKET, (54, 'Connection reset by peer')) instead of raise MythError(MythError.CLOSEDSOCKET)
NB, the number 54 should be 104 for the Error 'Connection reset by peer'.
Could you test this change?
Yes, that fixes the problem.
Platform: Ubuntu 20.04 Linux mypvr 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux MythTV Version : v31.0+fixes.202111081900.25f1bb1d12~ubuntu20.04.1 MythTV Branch : fixes/31 Network Protocol : 91 Library API : 31.20200101-1 QT Version : 5.12.8 Options compiled in: linux profile use_hidesyms using_alsa using_oss using_pulse using_pulseoutput using_backend using_bindings_perl using_bindings_python using_bindings_php using_dvb using_firewire using_frontend using_hdhomerun using_vbox using_ceton using_hdpvr using_ivtv using_joystick_menu using_libcec using_libcrypto using_gnutls using_libdns_sd using_libfftw3 using_libxml2 using_lirc using_mheg using_opengl using_egl using_qtwebkit using_qtscript using_qtdbus using_taglib using_v4l2 using_x11 using_libbluray_external using_xrandr using_profiletype using_systemd_notify using_systemd_journal using_bindings_perl using_bindings_python using_bindings_php using_freetype2 using_mythtranscode using_opengl using_egl using_vaapi using_nvdec using_vdpau using_ffmpeg_threads using_mheg using_libass using_libxml2 using_libmp3lame
MythTV version: v31+fixes
Package version: libmyth-python 2:31.0+fixes.202111081900.25f1bb1d12~ubuntu20.04.1
Component: /usr/lib/python3/dist-packages/MythTV/utility/other.py /usr/lib/python3/dist-packages/MythTV/static.py
What steps will reproduce the bug?
I am writing a Python program (epgdiff) that uses the frontend API to navigate mythfrontend screens. During testing, I had my program connected to mythfrontend and then tried shutting down mythfrontend to see how my program would cope with that. When the socket connection to mythfrontend was closed, I got an exception from the libmyth-python code, as expected, but that exception caused another AttributeError exception because the name of the original exception was not defined anywhere.
The socket closed exception is generated in utitlity/other.py at line 374:
raise MythError(MythError.CLOSEDSOCKET)
But MythTV.MythError.CLOSEDSOCKET is undefined. I think it should be defined in "class ERRCODES( object ):" at line 225 in static.py, or perhaps it should be handled the same way as other exceptions in other.py, as MythError.SOCKET and a specific message.
What do you see instead?
stephen@mypvr:~/.mythtv$ epgdiff -G -l -i 1001 1002 1003 02:08:29.943 epgdiff debug output started 02:08:30.101 Existing epgdiff window not found 02:08:30.101 config_xml="" 02:08:32.787 self.first_programme=' Big Fat Gypsy Weddings' 02:08:42.736 event='Return:36' values={'selected': [' Big Fat Gypsy Weddings']} 02:08:42.736 Return 02:08:42.736 search_for_title: title='Big Fat Gypsy Weddings' 02:08:42.736 jumppoint: mainmenu 02:08:42.736 handle_event_loop_task_result: task=<Task finished name='Task-2' coro=<GUI.event_loop() done, defined at /usr/local/bin/epgdiff:1026> exception=AttributeError("type object 'MythError' has no attribute 'CLOSEDSOCKET'")> 02:08:42.736 handle_event_loop_task_result: e=AttributeError("type object 'MythError' has no attribute 'CLOSEDSOCKET'") Traceback (most recent call last): File "/usr/local/bin/epgdiff", line 1111, in
w.main()
File "/usr/local/bin/epgdiff", line 1105, in main
asyncio.run(self.run())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/bin/epgdiff", line 1098, in run
await asyncio.gather(self.get_lines_task, event_loop_task)
File "/usr/local/bin/epgdiff", line 1058, in event_loop
self.search_for_title(self.content[self.line_no][PLPL:])
File "/usr/local/bin/epgdiff", line 888, in search_for_title
self.gotoTitleSearch()
File "/usr/local/bin/epgdiff", line 876, in gotoTitleSearch
self.do_jump('mainmenu', 'mainmenu')
File "/usr/local/bin/epgdiff", line 851, in do_jump
if not self.fe.jump[jumppoint]:
File "/usr/lib/python3/dist-packages/MythTV/methodheap.py", line 546, in getitem
self._populate()
File "/usr/lib/python3/dist-packages/MythTV/methodheap.py", line 543, in _populate
self._points = dict(self._parent.send('jump'))
File "/usr/lib/python3/dist-packages/MythTV/connections.py", line 546, in send
res = self.recv()
File "/usr/lib/python3/dist-packages/MythTV/connections.py", line 558, in recv
res = self.socket.dlexpect(prompt, deadline=deadline)
File "/usr/lib/python3/dist-packages/MythTV/utility/other.py", line 374, in dlexpect
raise MythError(MythError.CLOSEDSOCKET)
AttributeError: type object 'MythError' has no attribute 'CLOSEDSOCKET'