Closed gerw closed 2 months ago
Coverage Report
File Stmts Miss Cover Missing luxtronik __init__.py 184 133 28% 39–51, 73–77, 80, 84–89, 93–97, 108–111, 119–121, 128–130, 137–139, 146–148, 157, 165–167, 170–173, 176–179, 182–198, 201–211, 214–226, 229–239, 243–245, 249–265, 269–270, 274–275, 286–288, 291, 294, 297, 300, 303–306, 309–312 __main__.py 21 21 0% 3–49 datatypes.py 275 1 99% 82 discover.py 40 34 15% 21–69 luxtronik/scripts dump_changes.py 43 43 0% 7–85 dump_luxtronik.py 26 26 0% 6–52 TOTAL 675 258 62%
Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|
122 | 0 :zzz: | 0 :x: | 0 :fire: | 0.762s :stopwatch: |
What will happen if we request to read more data that is provided by the socket? Can thete be any kind of dead lock in this way?
Good point. I think one should check that at least one byte is returned, see https://docs.python.org/3/library/socket.html#socket.socket.recv.
In case nothing is returned by recv
, the connection is lost. What to do in this case? Raise some error? Which one?
Sometimes
self._socket.recv
returns fewer bytes than requested (for me, this happens sometimes over VPN). The currenttry-check
inread_*
is not helpful, since it just skews up the readings, e.g., if we only get 2 bytes for parameter 1, the remaining 2 bytes are then feed into parameter 2 and so on...The current fix assures that the correct amount of bytes is read by introducing a new function
_read_bytes()
.