﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	mlocked
13092	Python BEConnection:backendCommand timeout too low and improper protocol implementation	angela.schmid@…	Raymond Wagner	"I use lossless_cut to export recordings to the video library which half of the time crashed:

CRITICAL - Export to MythVideo, aborting script.
           Error: invalid literal for int() with base 10: ''

The problem occurs only when the video disk had to spin up.

The root cause is a too low timeout of 10 seconds in the Python BEConnection class when calling QUERY_FILE_EXISTS.

I could identify the following problems:

{{{
lossless_cut 
which calls dataheap.py Video:open()
which calls mythproto.py ftopen(), can not provide a timeout, because the logic to use a backend is in the next method
which calls mythproto.py, path = FileOps(host, db=db).fileExists(filename, sgroup)
which calls mythproto.py backendCommand(), fileExists calls backendCommand and should provide a higher timeout.
which calls connections.py BEConnection:backendCommand(), with default timeout=10seconds
}}}

- A user application can not provide a higher timeout.
- fileExists calls backendCommand and should provide a higher timeout.
- BEConnection:backendCommand() should use a higher default timeout.


The exception is misleading and caused by *not* throwing a proper exception, when hit by a timeout:

{{{
BEConnection.backendCommand:
    if len(select([self.socket],[],[], timeout)[0]) == 0:
       # no data, return
       return u''
}}}

- The client application receives an empty string, instead of a response described in [https://www.mythtv.org/wiki/QUERY_FILE_EXISTS_(Myth_Protocol)] or an exception.
- ""no data, return empty string"", is there really such a response from the backend in the Myth protocol?"	Bug Report - Crash	closed	minor	needs_triage	Bindings - Python	0.28.1	medium	Trac EOL	python backendcommand timeout		0
