bluesky / event-model

data model for event-based data collection and analysis
https://blueskyproject.io/event-model
BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

record descriptor uuid before executing subfactory callbacks in RunRouter.descriptor() #210

Closed jklynch closed 3 years ago

jklynch commented 3 years ago

Description

This PR moves the code in method RunRouter.descriptor() that records descriptor uuids in RunRouter._start_to_descriptors and RunRouter._descriptor_to_start so it will execute before subfactory callbacks are executed. The intention is to guarantee the dictionaries will be updated even if a callback raises an exception.

Motivation and Context

Currently if a callback executed by RunRouter.descriptor() raises an exception these dictionaries will not be updated with the descriptor uuid. Subsequent calls to RunRouter.event() with event documents referencing the same descriptor will then fail because the descriptor uuid will not be found in RunRouter._descriptor_to_start.

Closes #209.

How Has This Been Tested?

The test function test_subfactory_callback_exception has been added to test_run_router.py.

danielballan commented 3 years ago

Bump @gwbischof Can you review this one?