Giter VIP home page Giter VIP logo

Comments (5)

newville avatar newville commented on June 3, 2024

@kingspride One of the slightly tricky parts here is that the monitor callback is registered from the main Python loop but is called from "inside" the C-level CA event loop. That puts some subtle limitations on the work that can be done within each callback. One thing that basically cannot be done is to do other CA work, such as creating PVs or checking the connection status of other PVs. You can get other PV values, but those will essentially be the cached values.

So, what I do and recommend often (though I would hesitate to call this "the right way", is to just set a simple global/class-level field in the callback and then do the work such as "start long running task" from the main loop.

Does that make sense?

from pyepics.

kingspride avatar kingspride commented on June 3, 2024

okay. usage of global variables are not the "fine english way" as you'd say in german, but I can definitly use it if there is no other option.

from pyepics.

newville avatar newville commented on June 3, 2024

Well, your runner, run, worker, starter, stopper, and main are global variables, and you are using global throughout your script. Another completely normal approach would be to encapsulate that into a class, and have each of those be attributes/methods of the instance of the object (and then nothing would be global in your script and instead be owned by self).

But also, information and data about CA connections do need to be in "per-process" global data. That is done behind the scenes, but it can be useful to keep in mind that there is a single CA event loop running within the C-level CA library.

from pyepics.

kingspride avatar kingspride commented on June 3, 2024

sure, but initially I didnt want to use at least the global statement. maybe its just personal taste.

the script above was already a later version where I tried a lot of things (bluesky and ophyd devices dont work inside pyepics multiprocesses... :( )
so yeah...

I'll try to make my way though it with globals / classes and see where I get.
thanks so far :)

from pyepics.

newville avatar newville commented on June 3, 2024

@kingspride well, yeah there is also the question of "multiprocess" is actually what you want, especially in contrast to running multiple processes (ie, launched by the OS).

I can't help with anything related to ophyd/bluesky - I don't use it.

from pyepics.

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.