Skip to content

Invalid file descriptor error after listing resources #507

@MauroPfister

Description

@MauroPfister

After a call to ResourceManager.list_resources() my script terminates with the following exception:

Exception ignored in: <function BaseEventLoop.__del__ at 0x7accb1c73250>
Traceback (most recent call last):
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/asyncio/base_events.py", line 687, in __del__
    self.close()
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/asyncio/unix_events.py", line 68, in close
    super().close()
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/asyncio/selector_events.py", line 87, in close
    self._close_self_pipe()
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/asyncio/selector_events.py", line 94, in _close_self_pipe
    self._remove_reader(self._ssock.fileno())
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/asyncio/selector_events.py", line 272, in _remove_reader
    key = self._selector.get_key(fd)
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/selectors.py", line 191, in get_key
    return mapping[fileobj]
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/selectors.py", line 72, in __getitem__
    fd = self._selector._fileobj_lookup(fileobj)
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/selectors.py", line 226, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/home/mauro/.pyenv/versions/3.10.7/lib/python3.10/selectors.py", line 42, in _fileobj_to_fd
    raise ValueError("Invalid file descriptor: {}".format(fd))

This only happens under PyVISA-py 0.8.0. Prior versions work fine.

To Reproduce

Steps to reproduce the behavior:

  1. Run the following code snippet:
    import pyvisa
    
    rm = pyvisa.ResourceManager("@py")
    rm.list_resources()
    rm.close()

Output of pyvisa-info

Machine Details:
   Platform ID:    Linux-6.8.0-60-generic-x86_64-with-glibc2.39
   Processor:      x86_64

Python:
   Implementation: CPython
   Executable:     /home/mauro/.pyenv/versions/3.10.7/envs/instruments/bin/python3.10
   Version:        3.10.7
   Compiler:       GCC 8.5.0
   Architecture:   ('x86', 64)
   Build:          Nov  7 2022 15:27:13 (#main)
   Unicode:        UCS4

PyVISA Version: 1.15.0

Backends:
   ivi:
      Version: 1.15.0 (bundled with PyVISA)
      #1: /usr/lib/x86_64-linux-gnu/libvisa.so.25.3.0:
         found by: auto
         architecture:
            ('x86', 64)
         Vendor: National Instruments
         Impl. Version: 26215168
         Spec. Version: 7340032
   py:
      Version: 0.8.0
      TCPIP INSTR: Available 
         Resource discovery:
         - VXI-11: ok
         - hislip: ok
      TCPIP SOCKET: Available 
      PRLGX_TCPIP INTFC: Available 
      GPIB INSTR: Available 
      ASRL INSTR:
         Please install PySerial (>=3.0) to use this resource type.
         No module named 'serial'
      USB INSTR:
         Please install PyUSB to use this resource type.
         No module named 'usb'
      USB RAW:
         Please install PyUSB to use this resource type.
         No module named 'usb'
      VICP INSTR:
         Please install PyVICP to use this resource type.
      PRLGX_ASRL INTFC:
         Please install PySerial (>=3.0) to use this resource type.
         No module named 'serial'
      GPIB INTFC:
         Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
         No module named 'gpib'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions