Skip to content

Commit 86dc456

Browse files
jamesh1999Kludex
andauthored
Flush the stdout buffer on Windows to trigger reload (#2604)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
1 parent 695820a commit 86dc456

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

uvicorn/supervisors/basereload.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def restart(self) -> None:
9090
self.is_restarting = True
9191
assert self.process.pid is not None
9292
os.kill(self.process.pid, signal.CTRL_C_EVENT)
93+
94+
# This is a workaround to ensure the Ctrl+C event is processed
95+
sys.stdout.write(" ") # This has to be a non-empty string
96+
sys.stdout.flush()
9397
else: # pragma: py-win32
9498
self.process.terminate()
9599
self.process.join()

0 commit comments

Comments
 (0)