Prevent apps from hanging when running in reload mode and error occurs (#2394)

* Fix show_error in blocks

* dd to changelog + test
This commit is contained in:
Freddy Boulton 2022-10-04 16:10:02 -04:00 committed by GitHub
parent c3306721a4
commit a03d0ebe7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -52,6 +52,7 @@ No changes to highlight.
* Adds ability to disable pre/post-processing for examples [@abidlabs](https://github.com/abidlabs) in [PR 2383](https://github.com/gradio-app/gradio/pull/2383)
* Copy changelog file in website docker by [@aliabd](https://github.com/aliabd) in [PR 2384](https://github.com/gradio-app/gradio/pull/2384)
* Lets users provide a `gr.update()` dictionary even if post-processing is diabled [@abidlabs](https://github.com/abidlabs) in [PR 2385](https://github.com/gradio-app/gradio/pull/2385)
* Fix bug where errors would cause apps run in reload mode to hang forever by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2394](https://github.com/gradio-app/gradio/pull/2394)
## Contributors Shoutout:
No changes to highlight.

View File

@ -434,6 +434,7 @@ class Blocks(BlockContext):
self.share = False
self.enable_queue = None
self.max_threads = 40
self.show_error = True
if css is not None and os.path.exists(css):
with open(css) as css_file:
self.css = css_file.read()
@ -786,7 +787,6 @@ class Blocks(BlockContext):
block_fn.total_runs += 1
predictions = self.postprocess_data(fn_index, result["prediction"], state)
return {
"data": predictions,
"is_generating": result["is_generating"],

View File

@ -224,6 +224,18 @@ class TestBlocksMethods(unittest.TestCase):
pass
mock_post.assert_called_once()
def test_show_error(self):
with gr.Blocks() as demo:
pass
assert demo.show_error
demo.launch(prevent_thread_lock=True)
assert not demo.show_error
demo.close()
demo.launch(show_error=True, prevent_thread_lock=True)
assert demo.show_error
demo.close()
class TestComponentsInBlocks:
def test_slider_random_value_config(self):