InvokeAI/tests
Lincoln Stein c7bdaf93b2
Fix: Shut down the server with one keyboard interrupt (#94) (#8936)
* Fix: Kill the server with one keyboard interrupt (#94)

* Initial plan

* Handle KeyboardInterrupt in run_app to allow single Ctrl+C shutdown

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

* Force os._exit(0) on KeyboardInterrupt to avoid hanging on background threads

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

Fix graceful shutdown to wait for download/install worker threads (#102)

* Initial plan

* Replace os._exit(0) with ApiDependencies.shutdown() on KeyboardInterrupt

Instead of immediately force-exiting the process on CTRL+C, call
ApiDependencies.shutdown() to gracefully stop the download and install
manager services, allowing active work to complete or cancel cleanly
before the process exits.

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

* Make stop() idempotent in download and model install services

When CTRL+C is pressed, uvicorn's graceful shutdown triggers the FastAPI
lifespan which calls ApiDependencies.shutdown(), then a KeyboardInterrupt
propagates from run_until_complete() hitting the except block which tries
to call ApiDependencies.shutdown() a second time.

Change both stop() methods to return silently (instead of raising) when
the service is not running. This handles:
- Double-shutdown: lifespan already stopped the services
- Early interrupt: services were never fully started

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

Fix shutdown hang on session processor thread lock (#108)

* Initial plan

* Fix shutdown hang: wake session processor thread on stop() and mark daemon

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

* Fix: shut down asyncio executor on KeyboardInterrupt to prevent post-generation hang (#112)

Fix: cancel pending asyncio tasks before loop.close() to suppress destroyed-task warnings
Fix: suppress stack trace when dispatching events after event loop is closed on shutdown
Fix: cancel in-progress generation on stop() to prevent core dump during mid-flight Ctrl+C

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
2026-03-05 22:01:40 -05:00
..
app fix(model-install): persist remote access_token for resume after restart (#8932) 2026-03-02 02:44:21 +00:00
backend Feature: Add FLUX.2 LOKR model support (detection and loading) (#8909) 2026-02-27 00:45:13 +00:00
fixtures test: clean up & fix tests 2024-03-01 10:42:33 +11:00
inpainting Rename default schedulers across the app 2023-05-12 03:44:20 +12:00
model_identification Feature: Add FLUX.2 LOKR model support (detection and loading) (#8909) 2026-02-27 00:45:13 +00:00
test_model_manager prevent vae: '' from crashing model 2023-08-10 17:33:04 -04:00
__init__.py parent 9eed1919c2 2023-02-24 18:57:02 -08:00
conftest.py feat(multiuser mode): Support multiple isolated users on same backend (#8822) 2026-02-26 23:47:25 -05:00
dangerously_run_function_in_subprocess.py tests: add util to run a function in separate process 2025-03-06 07:49:35 +11:00
dev_prompts.txt Added linux to the workflows (#463) 2022-09-16 17:46:57 -04:00
legacy_tests.sh Add back old dream.py as legacy_api.py 2022-10-12 20:35:56 -04:00
test_asyncio_shutdown.py Fix: Shut down the server with one keyboard interrupt (#94) (#8936) 2026-03-05 22:01:40 -05:00
test_config.py feat(nodes): add methods to invalidate invocation typeadapters 2025-03-31 19:15:59 +11:00
test_dangerously_run_function_in_subprocess.py tests: add util to run a function in separate process 2025-03-06 07:49:35 +11:00
test_docs.py update config docstring 2024-08-08 15:20:43 -04:00
test_graph_execution_state.py Implemented ordering for expanded iterators (#8741) 2026-02-01 05:00:04 +00:00
test_imports.py Set ordering 2025-03-25 19:21:14 +11:00
test_invocation_cache_memory.py tests: add invocation cache tests 2024-03-06 08:14:12 -05:00
test_item_storage_memory.py chore(item-storage): improve types 2024-02-03 07:34:06 -05:00
test_model_hash.py feat(mm): rename "blake3" to "blake3_multi" 2024-03-22 08:26:36 +11:00
test_model_search.py tidy(mm): ModelSearch cleanup 2024-03-10 12:09:47 +11:00
test_node_graph.py Implemented ordering for expanded iterators (#8741) 2026-02-01 05:00:04 +00:00
test_nodes.py tests(app): add failing test for collector edge case 2025-06-30 23:39:28 +10:00
test_object_serializer_disk.py tests: update tests/test_object_serializer_disk.py 2025-04-04 18:42:13 +11:00
test_path.py chore: ruff 2024-03-01 10:42:33 +11:00
test_profiler.py feat: add profiler util (#5601) 2024-01-31 10:51:57 +00:00
test_session_queue.py tidy(app): document & clean up batch prep logic 2025-02-26 21:04:23 +11:00
test_sqlite_migrator.py feat(multiuser mode): Support multiple isolated users on same backend (#8822) 2026-02-26 23:47:25 -05:00
validate_pr_prompt.txt fixes to env parsing, textual inversion & help text 2023-05-18 10:48:23 -04:00