Git Product home page Git Product logo

Comments (4)

coretl avatar coretl commented on August 29, 2024 1

And you can pass loop to RE and it will use that one, so maybe it should default to using the current one rather than making its own if it is within an event loop?

from ophyd-async.

evalott100 avatar evalott100 commented on August 29, 2024 1

@coretl, @callumforrester, @OCopping and I had a meeting on this. we agreed to leave things how they are, but add documentation. A summary of how things currently work:

image

with DeviceCollector

On exit we call in the bluesky event-loop

    def __exit__(self, type_, value, traceback):
        self._objects_on_exit = self._caller_locals()
        return call_in_bluesky_event_loop(self._on_exit())

call_in_bluesky_event_loop will fail if the bluesky event loop isn't running.

async with DeviceCollector

We don't force the bluesky event-loop, it's down to the user to choose to run in the same event loop.

    async def _on_exit(self) -> None:
        # Name and kick off connect for devices
        connect_coroutines: Dict[str, Coroutine] = {}
        for name, obj in self._objects_on_exit.items():
            if name not in self._names_on_enter and isinstance(obj, Device):
                if self._set_name and not obj.name:
                    obj.set_name(name)
                if self._connect:
                    connect_coroutines[name] = obj.connect(
                        self._sim, timeout=self._timeout
                    )

        # Connect to all the devices
        if connect_coroutines:
            await wait_for_connection(**connect_coroutines)

    async def __aexit__(self, type, value, traceback):
        self._objects_on_exit = self._caller_locals()
        await self._on_exit()



# Later when setting up the RunEngine:
RE(loop=the_loop_used_when_setting_up_the_devices)

from ophyd-async.

coretl avatar coretl commented on August 29, 2024

At the moment the RE is only require if you do with DeviceCollector(): and if you do motor.move() rather than await motor.set(). For the first, if you do async with DeviceCollector(): within an event loop it will work fine, and for the second I think we should ditch motor.move() and do this with magics instead

from ophyd-async.

callumforrester avatar callumforrester commented on August 29, 2024

+1 to defaulting to current loop, would be good minimize coupling between ophyd async and bluesky

from ophyd-async.

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.