# ask-community

Kris Kim

07/14/2023, 6:58 AM
Hi, I want to implement below logic We have file_detect_sensor that detect a new file in s3 and execute a run against the file The logic will be 1. Detect 10 consecutive run failures (Maybe failure_sensor detect this) 2. Turn off the file_detect_sensor 3. Send a email to notify people that dagster job is turned off 4. Set the cursor value of file_detect_sensor to last successful file 5. Clear the run queue (since there can be 100s of runs and they will be failed as well) 3,4 is quite clear for me but can you recommend best way to implement 1,2,5? I want to know if we can implement these by using library methods or we should implement those by using our own flags or counters.
👀 1