From 78d0a256f2f5c8fb9c5e88e9339457757fe5edad Mon Sep 17 00:00:00 2001 From: Ron Quan Date: Wed, 18 Oct 2017 12:55:49 -0700 Subject: [PATCH 1/2] Fixing resource warning for sqltoolsservice by closing stdout after killing process. --- mssqlscripter/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mssqlscripter/main.py b/mssqlscripter/main.py index 7bed0b5..eb29b95 100644 --- a/mssqlscripter/main.py +++ b/mssqlscripter/main.py @@ -106,6 +106,10 @@ def main(args): tools_service_process.kill() # 1 second time out, allow tools service process to be killed. time.sleep(1) + # Close the stdout file handle or else we would get a resource warning (found via pytest). + # This must be closed after the process is killed, otherwise we would block because the process is using + # it's stdout. + tools_service_process.stdout.close() # None value indicates process has not terminated. if not tools_service_process.poll(): sys.stderr.write( From 45dc8d3788a2c7dc0b97da80fd33545a97d534de Mon Sep 17 00:00:00 2001 From: Ron Quan Date: Thu, 19 Oct 2017 09:42:08 -0700 Subject: [PATCH 2/2] Shortening sleep time during shutdown. --- mssqlscripter/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mssqlscripter/main.py b/mssqlscripter/main.py index eb29b95..bd3d1d2 100644 --- a/mssqlscripter/main.py +++ b/mssqlscripter/main.py @@ -105,7 +105,7 @@ def main(args): sql_tools_client.shutdown() tools_service_process.kill() # 1 second time out, allow tools service process to be killed. - time.sleep(1) + time.sleep(.1) # Close the stdout file handle or else we would get a resource warning (found via pytest). # This must be closed after the process is killed, otherwise we would block because the process is using # it's stdout.