Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.0
current_version = 0.9.1
files = SQLTools.py
tag = True
commit = True
Expand Down
2 changes: 1 addition & 1 deletion SQLTools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "v0.9.0"
__version__ = "v0.9.1"

import sys
import os
Expand Down
21 changes: 20 additions & 1 deletion SQLToolsAPI/Command.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ def run(self):
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW

# select appropriate file handle for stderr
# usually we want to redirect stderr to stdout, so erros are shown
# in the output in the right place (where they actually occurred)
# only if silenceErrors=True, we separate stderr from stdout and discard it
stderrHandle = subprocess.STDOUT
if self.silenceErrors:
stderrHandle = subprocess.PIPE

self.process = subprocess.Popen(self.args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stderr=stderrHandle,
stdin=subprocess.PIPE,
env=os.environ.copy(),
startupinfo=si)
Expand All @@ -52,6 +60,9 @@ def run(self):
'replace').replace('\r', ''))

queryTimerEnd = time.time()
# we are done with the output, terminate the process
self.process.terminate()

if 'show_query' in self.options and self.options['show_query']:
resultInfo = "/*\n-- Executed querie(s) at {0} took {1:.3f}ms --".format(
str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(queryTimerStart))),
Expand All @@ -61,6 +72,10 @@ def run(self):
resultInfo, resultLine, self.query, resultLine)
return self.callback(resultString)

return

# regular mode is handled with more reliable Popen.communicate
# which also terminates the process afterwards
results, errors = self.process.communicate(input=self.query.encode())

queryTimerEnd = time.time()
Expand Down Expand Up @@ -110,6 +125,10 @@ def stop(self):
if not self.process:
return

# if poll returns None - proc still running, otherwise returns process return code
if self.process.poll() is not None:
return

try:
# Windows does not provide SIGKILL, go with SIGTERM
sig = getattr(signal, 'SIGKILL', signal.SIGTERM)
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"0.3.0": "messages/v0.3.0.md",
"0.3.1": "messages/v0.3.0.md",
"0.8.2": "messages/v0.8.2.md",
"0.9.0": "messages/v0.9.0.md"
"0.9.0": "messages/v0.9.0.md",
"0.9.1": "messages/v0.9.1.md"
}
11 changes: 11 additions & 0 deletions messages/v0.9.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## v0.9.1 Notes

### Improvements

* Display errors inline instead of appending them at the bottom [#92](https://github.com/mtxr/SQLTools/issues/92)


### Fixes

* Thread timeout is always triggered when streaming results output (MacOS) [#90](https://github.com/mtxr/SQLTools/issues/90)
* stderr output is ignored when streaming results output [#91](https://github.com/mtxr/SQLTools/issues/91)