Skip to content

Async Running Problem with AsyncRunner #450

Open
@hz-xiaxz

Description

@hz-xiaxz

Description:
As a newcomer to this package, I'm exploring the usage of the AsyncRunner feature, particularly aiming to employ the start_periodical_saving functionality. Below is the code snippet I've implemented:

runner = adaptive.Runner(learner, executor=executor, npoints_goal=100)
runner.start_periodic_saving(
    {"fname": f"./config/{data.nx}x{data.ny}_{data.mode}.pkl", "compress": True},
    interval=30,
)
runner.ioloop.run_until_complete(runner.task)

Since the AsyncRunner doesn't work well in a script environment, I ran it in a jupyternotebook using the %run magic command, and got the error message pointing to runner.ioloop.run_until_complete(runner.task)

RuntimeError: This event loop is already running

I suspect that the conflict arises because the runner.start_periodic_saving coroutine initiates its own event loop, which contradicts the use of run_until_complete function. Since run_until_complete is crucial for me as it ensures sequential execution of subsequent functions after runner.task completion, I'm seeking guidance on resolving this issue.

Request for Assistance:
Could you provide guidance on how to address this conflict and enable the sequential execution of functions following runner.task completion, given the necessity of using run_until_complete?

Apology for encountering another issue within such a short timeframe. Your package is truly remarkable and has significantly contributed to the success of my project. Thanks for your kind assistance

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