Open belisarius222 opened 8 years ago
What happens when the function doesn't return in the specified time frame? Does it kill the thread? That would be really bad. Is there a chance that it's going to interfere with other running tests? I don't think I like this direction, personally.
Ok.
I can see how this might not be the best direction for nose, considering how general it needs to be. Adding a thread does introduce more complexity, and now that you mention it, I can see some troublesome edge cases. It should really run the function's teardown if it didn't complete, for example.
I felt compelled to write this because I kept putting @timed() decorators on tests, expecting the decorator to flag them as failures if they didn't complete in time, but instead the test will continue on, even if it's hanging. I need something like this function to test certain pieces of code that tend to hang if they're not working properly, mostly multiprocessing-related.
The timed() decorator used to wait indefinitely for its test function to return. Now it runs the test function in a new thread, and if the function doesn't return within the specified time limit, it throws a TimeExpired error.