pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
288 stars 124 forks source link

Deadlock on Read with TCPIP Socket #61

Closed mluthi closed 6 years ago

mluthi commented 9 years ago

In debugging a problem with reading data from a device using the TCPIP socket connection I discovered a problem in the read method of the TCPIPSocketSession class (ln. 391ff in tcpip.py; version 0.3.dev0): the select function is called without a timeout and therefore may block indefinitely in case the VI_ATTR_TERMCHAR_EN attribute is not set. In my case the while loop is executed once in the beginning to receive the data and then blocks forever the second time it gets to the select call.

My environment: Windows 7 Enterprise, SP1, Python 3.4.1

Best Regards, Matthias

petervago commented 8 years ago

I experienced the same. (Ubuntu 14.04. 64bit) The following solved the issue for me:

Replaced the following code: /usr/local/lib/python3.4/dist-packages/pyvisa-py/tcpip.py line 391

select.select([self.interface], [] , [])

with this:

try:
 select.select([self.interface], [] , [] , 0.01) # timeout 0.01sec
 last = read_fun(chunk_length)
except:
 last = ""

Regards, Peter

skrchnavy commented 7 years ago

in #107 there shall be implemented fix for this issue. Tested on windows only for now.

skrchnavy commented 6 years ago

107 merged, #113 improves implementation. When merged or closed, this issue can be also closed as resolved.

MatthieuDartiailh commented 6 years ago

Closed by #113