1

I am having problems using pyVisa library for port communication, because it sometimes output alot of repeated information to the console (e.G):

Comm::LockCheck: sess=122e248, isDevSess=0, locssess=0, pid=6220, lockpid=0

Devsess can be locked.

Intfsess can be locked.

I have tried redirecting stdout as suggested in alot of other post (e.g):

@contextlib.contextmanager
def suppress_stdout():
with open(os.devnull, "w") as devnull:
    old_stdout = sys.stdout
    sys.stdout = devnull
    try:  
        yield
    finally:
        sys.stdout = old_stdout 

This suppresses my own print commands when used, but does not prevent the library from printing.

Preferably any suggestion should be safe to use in Thread. (I known that the attempted code is not)

Community
  • 1
  • 1
Qtra
  • 21
  • 4
  • probably because the library is using native commands / code which issues `printf`s, not accounted in python output. – Jean-François Fabre Sep 01 '17 at 08:18
  • I have tried to answer by a hack here: https://stackoverflow.com/questions/45881274/remove-output-of-all-subprocesses-in-python-without-access-to-code/45881484#45881484 – Jean-François Fabre Sep 01 '17 at 08:20
  • @Jean-FrançoisFabre it seems that the library does not use the subprocess.py or atleast, I can't figure out a way to force the use of the copied file. The package is installed in pythonpath under lib, and is actually a wrapper for a seperate library, which I don't have the source files for. – Qtra Sep 01 '17 at 08:47

0 Answers0