Skip to content

How to turn on error msgs in the main loop? #93

Answered by coretl
nussfluss asked this question in Q&A
Discussion options

You must be logged in to vote

This is a failing of the example code. We put some exception handling in the dispatcher, so if an function passed to on_update fails we get the traceback printed, but we don't do anything with the long running update function in the example. We can make use of the same exception handling by scheduling it with the dispatcher:

...
# Start processes required to be run after iocInit
async def update():
    while True:
        ai.set(ai.get() + 1)
        await asyncio.sleep(1)
        raise Exception("Boom")

dispatcher(update)

# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())

This now prints

Starting iocInit
#######################################…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@nussfluss
Comment options

@coretl
Comment options

Answer selected by Araneidae
@nussfluss
Comment options

@nussfluss
Comment options

@AlexanderWells-diamond
Comment options

@nussfluss
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants