FirebirdSQL / python3-driver

Firebird driver for Python that uses new Firebird API
https://www.firebirdsql.org/en/devel-python-driver/
MIT License
27 stars 10 forks source link

Add optional timeout when reading a line of output from a service manager #12

Closed qweqq closed 2 years ago

qweqq commented 2 years ago

This is useful when trying to read a line of output from a Trace session where a timeout of 1 second (or more) seems mandatory, otherwise the readline() call blocks indefintely. See #11

pcisar commented 2 years ago

I can't accept this patch as it does not work as you expect.

First, although Server._query_output() and Server._read_output() support "timeout" parameter, they actually does not support timed out responses. They do not detected timed out requests (like Server._fetch_line() does) at all, and hence does not respond reliably. If it worked for you in your specific scenario, it was pure coincidence.

Second, handling service output with timeout support is not trivial as there could be LINE or TO_EOF modes, internal buffering. multiple low-level requests to make a single output line etc. I was not able yet to find arrangement that could handle timeouts reliably in all situations. If firebird-driver would ever support timeout for service output, it will be completely separate method than redline() with specific behavior (mind that readline() is also used by readlines() and iterator protocol).