Closed AR-234 closed 2 years ago
I think adding a timeout is a good idea. A good use case could be to ask Kalandralang to run a recipe as many times as possible for, say, 1 minute.
However it looks like in your implementation the timeout cannot interrupt a craft that is in progress and I wonder whether it should. For instance if there is a very long craft the timeout could be used to stop it before the end to still ensure that the total run duration is not too long.
Another improvement is that I think currently Ctrl+C interrupts everything and causes Kalandralang to not display the cost summary at the end. Ctrl+C could act like a timeout in that regard: stop the current craft but still show the summary up to this point.
I can implement both improvements quite easily, but I'd like your opinion first :)
I implemented this timeout so it does exit in a safe state, but you got a point for very long crafts. I wanted to ensure that in the end if you get a really long craft have at least one useable craft to display even if you set the timeout to low, but maybe this shouldn't be our problem..
Actually I was thinking about implementing the ctrl+c approach aswell, but figure out what exception is called to redirect it to endcraft.. So would be awesome if you could add it.
Same thing with aborting the craft at the next parsing step. I don't think we should add an other flag for that, so my gut tells me if the user sets the time to low it is his problem..
Ok changed some things around, and tested it seems to work pretty well. Tell me if you find something I should change :)
Ok tweaked a lot of this like you said. But haven't changed it from while to for, because of #discussion_r861300923
Maybe one thing could be to rename runCount
to something more clear e.g. run_index
or somthing
Adds a timeout for batches which safly terminates them if threshold is reached. (Just doesn't continue)
Whats your thought?