Giter VIP home page Giter VIP logo

Comments (7)

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

Could you provide a sample script illustrating your issue ?

from pyvisa-sim.

bilderbuchi avatar bilderbuchi commented on August 19, 2024

Not sure what @yn4k4nishi means, but I also observe weird problems running pytest tests with pyvisa-sim backed fixture objects, in that replies remain in a read buffer despite the objects + resource managers being destroyed:

>>> import pyvisa
>>> rm = pyvisa.ResourceManager(visa_library='@sim')
>>> instr = rm.open_resource('ASRL2::INSTR')
>>> instr.write('*IDN?')
7
>>> instr.read()
'SCPI,MOCK,VERSION_1.0\n'  # OK, that's what I expect
>>> instr.write('*IDN?')  # we don't fetch that response from the instrument
7
>>> id(instr)
140011221241280
>>> del instr  # Kill the instrument
>>> del rm
>>> rm = pyvisa.ResourceManager(visa_library='@sim')
>>> instr = rm.open_resource('ASRL2::INSTR')
>>> instr.read()  # Why is this response in this different instrument object?
'SCPI,MOCK,VERSION_1.0\n'
>>> id(instr)
140011221241472  # the IDs of the instr objects are different, so it's not somehow the same

Is that expected?

from pyvisa-sim.

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

Here you are assuming that when you delete the instr and the resource manager they instantaneously go away. This may not be true because the rm and the library object are in a reference cycle and the gc may dispose of them only later on. Could you run the same code but explicitly closing the instr and rm rather than relying on __del__ being invoked.

from pyvisa-sim.

bilderbuchi avatar bilderbuchi commented on August 19, 2024

Ah, you are right. instr.close() is neither sufficient nor necessary, rm.close() does the trick. Thanks!
Argh, Python's behaviour around __del__ is annoying at times. 😠

from pyvisa-sim.

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

The fact that closing the instrument does not solve the issue still says that something is off. Instruments do not share outgoing buffers between connections and we should mimic that.

from pyvisa-sim.

bilderbuchi avatar bilderbuchi commented on August 19, 2024

The fact that closing the instrument does not solve the issue still says that something is off. Instruments do not share outgoing buffers between connections and we should mimic that.

@MatthieuDartiailh is that something that still should be followed up separately? (to avoid this disappearing in a closed issue comment)

from pyvisa-sim.

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

It would make sense yes

from pyvisa-sim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.