-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Reset spyder and restart from within running application #2423
Conversation
I would put it in the general tab in the preferences window. |
That feels weird, cause the preferences tab defines behaviors not actions. This is an action, and it would be nice if it has a straightforward place for it. |
Yeah, but it is an action applied to the behaviors ! |
In that case I prefer adding the extra button. Opinions @spyder-ide/core-developers? |
@blink1073, @SylvainCorlay, @ccordoba12 any comments on this one? |
I like it as part of the Tools menu, as it is a global action. |
@SylvainCorlay? @ccordoba12 comments? |
I really think that resetting the preferences should be done from the preference window. That's the same reason why resetting shortcuts is done from the shortcuts tab. |
I understand my dear, that is why I said, if it was going to be there, then it should be a button next to apply, ok, cancel, etc.... But I would like to hear from @SylvainCorlay and @ccordoba12 |
@Nodd there might be a reason to keep the restart option outside. Sometimes if there is an error or conflict the preferences dialog might not open, in which case restarting and reseting could not be done from within the gui. |
#2412 should lower the probability of this happening. Also it's still possible to use the commandline switch or remove the directory by hand (of course it's less user-friendly). |
@@ -943,4 +950,4 @@ def apply_settings(self, options): | |||
if self.main.historylog is not None: | |||
self.main.historylog.apply_plugin_settings(['color_scheme_name']) | |||
if self.main.inspector is not None: | |||
self.main.inspector.apply_plugin_settings(['color_scheme_name']) | |||
self.main.inspector.apply_plugin_settings(['color_scheme_name']) |
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.
Missing a newline here
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.
oops
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.
Fixed
@Nodd Fixed |
pid_reset = p.pid | ||
except Exception as error: | ||
print(command) | ||
print(error) |
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.
Using the traceback
module would be nicer here, since it prints the full traceback as if the Exception wasn't catched. You can use traceback.print_exc()
with no arguments, it prints the right thing at the right place.
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.
Great, I will do :)
@Nodd so you suggest something regarding the "infinite" loop?... or should we just let it roll and see how it works? |
@@ -713,6 +713,9 @@ def create_edit_action(text, tr_text, icon): | |||
module_completion.reset(), | |||
tip=_("Refresh list of module names " | |||
"available in PYTHONPATH")) | |||
reset_spyder_action = create_action( | |||
self, _("Reset Spyder to factory defaults"), | |||
triggered=lambda: self.reset_spyder()) |
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.
You can avoid the lambda here I think, using self.reset_spyder
directly
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.
True!
I think the correct behaviour is to wait something like 30s, and if it's not finished, kill the process, stop the restart and display a QMessageBox with an error. |
except Exception as error: | ||
print(command) | ||
traceback.print_exc() | ||
time.sleep(15) |
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.
If there is a problem here, the restart should be stopped instead of waiting 15s. This way the error will show up in the internal console.
Actually that means that you don't need to use traceback.print_exc()
, just reraise the exception!
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.
I am not sure I get you... by internal console you mean? at this point we already left the initial spyder instance and we are inside the restart script. I will add an extra flag so that the restart stops and a QMessageBox displays something.
Ok @Nodd I added a series of checks for better error handling which include a display of a message box in case errors occur, including close, reset and restart errors. Errors catched in the try,except part will also display the actual error. Errors based on too long running time will not display the error, but a friendly message.... |
while True: | ||
max_counter = 1500 # Max loops to perform before aborting | ||
counter = 0 | ||
while counter < max_counter: # This is equivalent to ~ 5 minute (1500*0.2) |
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.
A for
loop maybe ? ;)
# Before launching a new Spyder instance we need to make sure that the | ||
# previous one has closed. We wait for a fixed and "reasonable" amount of | ||
# time and check, otherwise an error is launched | ||
wait_time = 60*5 if IS_WINDOWS else 60*3 # Seconds |
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.
So we discussed this with @blink1073 and @SylvainCorlay and all of us agree that these waiting times are way too big. We think nobody is going to wait 3 min, much less 5 min, for Spyder to start :-)
So our proposal for this is: 30 sec for Linux/Mac (perhaps even 20), and 75 sec (90 tops) for Windows.
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.
Ok Done...
30 and 90
Any my mental health @ccordoba12 ? |
Anything holding this @ccordoba12? |
RESTART_ERROR: _("Spyder restart error")} | ||
|
||
if error: | ||
e = error.__repr__() |
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.
Why is this necessary?
I think waiting 60 secs for Also, I'd like to discuss how the logic for reset + restart works. So |
Ok. When you restart first we wait for spyder to close. If that happenned before the max wait time then we launch the reset process, if that went fine and took less than the stated time then the new spyder instance is launched. |
So this means a user could have to wait up to (30 or 90) + 60 secs for a reset (plus the time it take for a new instance to appear). Can we reduce the time to reset to 20 secs or so? It usually doesn't take that long ;-) |
Yes, you are correct. Sure, 20 secs is fine (I guess... we will know otherwise!) |
Anything besides that ? |
Anything else @ccordoba12 ? |
Ok, merging this with @goanpeca (in person) for his own mental health :-P |
Reset spyder and restart from within running application
woot! |
Fixes #2401
Description
Adds a new entry on the tools menu for reseting spyder from within the application
Or as an option in preferences... decision pending
After clicking a message box will ask to confirm, probably the message can be more explanatory so the user knows what he\she is about to do.
Todo