New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When on the CLI, catch ctrl-c early in execution and exit cleanly #234
Conversation
Ha! Caught by my own test. |
pls move the comment about try/except vs init into the code, as a comment. This helps future maintainers. otherwise, looks good to me (lgtm) -- pls check with @dimaryaz as well. |
* Removed unecessary import in main.py * Exiting with ctrl-c produces a unique exit code (stored in const) * Noticed a bug in MockObject where exceptions were substituted, but shouldn't be. Fixed. * Testing ensures '--dev' is accepted * Testing ensures normal-mode traceback suppression * Testing ensures dev-mode traceback display
I'm not sure if it's ok for me to touch const.py, let me know if this isn't the best place for exit codes. I've considered that an 'errors.py' might be useful, which could include (all) exceptions and error codes. |
go ahead and touch whatever files you need - we're done with the merge.
ᐧ
…On Sun, Dec 10, 2017 at 6:24 PM, eode ***@***.***> wrote:
I'm not sure if it's ok for me to touch const.py, let me know if this
isn't the best place for exit codes.
I've considered that an 'errors.py' might be useful, which could include
(all) exceptions and error codes.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#234 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQUcPfYWiNFfDC5hi2NsYLz9Or67VVh6ks5s_JJBgaJpZM4Q8n4B>
.
--
You received this message because you are subscribed to the Google Groups
"Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ***@***.***
To post to this group, send email to ***@***.***
To view this discussion on the web visit https://groups.google.com/a/
quiltdata.io/d/msgid/dev/quiltdata/quilt-compiler/pull/
234/c350606745%40github.com
<https://groups.google.com/a/quiltdata.io/d/msgid/dev/quiltdata/quilt-compiler/pull/234/c350606745%40github.com?utm_medium=email&utm_source=footer>
.
|
return result | ||
return self.execute_fast(cli_args) | ||
|
||
def execute_cli(self, cli_args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dumb q: I thought [something like this] was already committed as part of the CLI testing? sorry if dumb q...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a dumb question -- that's just the original function, split into two functions, so that I could call the execute_cli() one separately. I ended up needing to use Popen, anyways, so it was moot. ..but I left the change in in case some future test has reason to prefer either execute_cli
or execute_fast
over using execute
, which auto-selects cli or fast mode based on environment.
One sec, I have a between-python-versions (or similar) portability issue that's not passing appveyor. I'll push a fix momentarily. |
I've pushed that change, but appveyor looks stuck (on a different test). |
I've removed some code to reset appveyor, but it looks like they're backlogged or something similar. In the mean time, don't merge this branch until I put the code back in and re-test that, even if appveyor passes in the mean time. |
appveyor has made a new test, but at this point at least one test is still hung (https://ci.appveyor.com/project/quiltdata/quilt-compiler/build/1.0.102, second test, at 52 minutes currently). |
Bad news: Appveyor is hung again. Looks like it can't handle ctrl-c events in testing. Amusingly, appveyor found a bug, and the fix led to the appveyor hang. In any case, the latest commit, 78cfca4, should still be executed on appveyor, but any running tests on this branch before that should be cancelled, if possible -- or, they'll drop off on their own eventually. The current fix xfails a suspect portion of code. If that doesn't work, I'll xfail the whole test in another commit. |
xtest is fine for now. I think we can get a local windows box (or cloud
VM) for faster testing.
…On Dec 11, 2017 6:47 AM, "eode" ***@***.***> wrote:
Bad news: Appveyor is hung again. Looks like it can't handle ctrl-c events
in testing.
Good news: That means we know why, and can prevent it from hanging by just
xfailing the test on windows.
Amusingly, appveyor found a bug, and the fix led to the appveyor hang.
In any case, the latest commit, 78cfca4
<78cfca4>,
should still be executed on appveyor, but any running tests on this branch
before that should be cancelled, if possible -- or, they'll drop off on
their own eventually.
The current fix xfails a suspect portion of code. If that doesn't work,
I'll xfail the whole test in another commit.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#234 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQUcPRnNHrhe7Rf3nERUzL-EFxDqkzieks5s_UCEgaJpZM4Q8n4B>
.
--
You received this message because you are subscribed to the Google Groups
"Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ***@***.***
To post to this group, send email to ***@***.***
To view this discussion on the web visit https://groups.google.com/a/
quiltdata.io/d/msgid/dev/quiltdata/quilt-compiler/pull/
234/c350745033%40github.com
<https://groups.google.com/a/quiltdata.io/d/msgid/dev/quiltdata/quilt-compiler/pull/234/c350745033%40github.com?utm_medium=email&utm_source=footer>
.
|
ready to roll. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__.py
looks like the wrong place to do it. Figuring out the executable name is hacky, and it's risky if we get it wrong and set the interrupt handler when we shouldn't.
I think our own entry point is the place to do it - i.e., the quilt
script that does if __name__ == '__main__'
. It's as early as it gets, and it only runs when quilt is run from the CLI.
Not sure if setup.py
has a way for us to customize the script... But even if it doesn't, it should be possible to wrap main
, or maybe write our own entry point script.
The pure and simple of it is, not only is it reasonable and supported, the consequences are minimal if we're incorrect. On top of that, the most inconvenient case is also the most improbable -- and we can solve it by a line of documentation somewhere about external usage: "Quilt does not support being imported by a program that spoofs sys.argv[0]. If you do so, it may suppress your tracebacks by replacing the interrupt handler for SIGINT." ..but really, we probably don't even need that, as it's just going to be noise to most people. In any case, I know of no mechanism for altering the actual entry point script, which is auto-generated by setuptools and/or pip during install, depending on the specifics of the system. If you know one, please let me know, because I'd like to know, it would be a cool tidbit to be aware of. Lastly, if we forego the entry-points system altogether (not recommended for more than one reason I'll not go into here), and use our own script, then we also must detect all of the interoperability differences between systems that many talented people in the pip and setuptools contributor pool have already found and fixed. ..and We could, however, implement lazy loading of modules, and move exception handling into a |
This still needs to be tested on Windows. I'll try to check into that when there's less that's pressing. |
ping re windows (if hard, then OK to defer windows support - add a comment) |
I'll look into it once I've got something useful on quilt export, so maybe the 20th, or I'll start on it on the 23rd. |
As far as I'm concerned, it's ready to go except that it hasn't been tested on Windows, and the specific test has been skipped because it crashes the Appveyor test. ..although, ironically Appveyor caught a related bug, and the fix led to the Appveyor test skip. Aside from that, I consider it done, but I can change it if @dimaryaz still wants a change. If it's here when my current TODO list is done, or if it's bumped up in priority by you @asah , I'll test it on Windows and check that off. |
Well, it'd be a pain to actually get the test working on Windows, and it's probably not worth the effort. However, I've manually verified that this works correctly. Unless we want to put additional time into the test re: windows, I'm good with this. @dimaryaz ? |
I'm good with that (manual testing for now).
ᐧ
…On Fri, Jan 5, 2018 at 12:58 PM, eode ***@***.***> wrote:
Well, it'd be a pain to actually get the test working on Windows, and it's
probably not worth the effort. However, I've manually verified that this
works correctly. Unless we want to put additional time into the test re:
windows, I'm good with this. @dimaryaz <https://github.com/dimaryaz> ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#234 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQUcPWMk4Vo3iPqL4NSe6NvQAXVKu15cks5tHozqgaJpZM4Q8n4B>
.
--
You received this message because you are subscribed to the Google Groups
"Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ***@***.***
To post to this group, send email to ***@***.***
To view this discussion on the web visit https://groups.google.com/a/
quiltdata.io/d/msgid/dev/quiltdata/quilt/pull/234/c355663662%40github.com
<https://groups.google.com/a/quiltdata.io/d/msgid/dev/quiltdata/quilt/pull/234/c355663662%40github.com?utm_medium=email&utm_source=footer>
.
|
Normally I'd just do a try: except: block on or in main(), but at load-time, we load a bunch of external modules that take a lot of time, during which ctrl-c will cause an exception that misses that block. ..so, this was added to
quilt/__init__.py
.Also, sometimes during development we want to be able to see the traceback -- for example, if we're wondering what's taking so long, or what function is causing network activity. Toward that end, there's now a variable
quilt._DEV_MODE
which enables/disables traceback.If your first argument is
--dev
, or if the environment hasQUILT_DEV_MODE=True
, tracebacks will still be shown. Help for--dev
is suppressed and doesn't show up inquilt help
,quilt --help
, etc.