From f24e80a91280b03b9d5307c49ca90a8dc16929c7 Mon Sep 17 00:00:00 2001 From: Anil P Date: Fri, 5 Feb 2021 06:22:39 -0600 Subject: [PATCH] Fixes #2527, ValueError: write to closed file from using JSII 1.20.0 with AWS CDK for Python3 --- .../python-runtime/src/jsii/_kernel/providers/process.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py index 428acfe0c5..ef960c90a4 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py @@ -282,9 +282,10 @@ def stop(self): # This process is closing already, un-registering the hook to not fire twice atexit.unregister(self.stop) - self._process.stdin.write(b'{"exit":0}\n') - # Close the process' STDIN, singaling we are done with it - self._process.stdin.close() + if not self._process.stdin.closed: + self._process.stdin.write(b'{"exit":0}\n') + # Close the process' STDIN, singaling we are done with it + self._process.stdin.close() try: self._process.wait(timeout=5)