-
-
Notifications
You must be signed in to change notification settings - Fork 3
Bugfix/run twice #10
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
Bugfix/run twice #10
Conversation
Better later than never.
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 did not try it in action but read through the code changes.
return new Promise(async (resolve, reject) => { | ||
if (this.reject_run) { | ||
this.reject_run('re run') | ||
this.reject_run = null |
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.
This line is not necessary here, but if you want to keep setting the rejected promise to null
, maybe you can have a method for all three occurrences.
function ensureRejected(message) {
if (this.reject_run) {
this.reject_run(new Error(message));
this.reject_run = null;
}
}
Any reason you prefer rejecting with a string
instead of an 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.
No, it should definitely be an error. I just don't find the helper function really helpful here. I'm also not sure if this is going to be the final solution ™️ so I'd prefer keeping things a bit more unrolled.
await this.exit_raw_repl() | ||
return resolve(output) | ||
} catch (e) { | ||
reject(e) |
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.
Question: if there is an error here, and the promise is rejected, then the next run
call will find this._reject_run
to be not null
and will reject it, but nothing will happen, as it has already been rejected. Is this expected behavior, or would it be better to set this.reject_run
to null
in the catch
?
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.
Thanks for the updates!
Problem:
If you press the button run twice a few breaking situation happen:
This will also make other functions to break (save, list files, etc...)
When entering raw repl again it executes some code automatically a couple of times.
When entering raw repl, typing 'print(123)' and hitting control+D will execute and leave raw repl. It should not leave raw repl.
Solution:
Board was getting stuck because promises weren't being "canceled".
Following cue from
micropython-ctl
implementation: The function to reject therun
promise is stored locally on board class and called before attempting other operations (stop and reset).Future improvement:
Renaming methods because right now it's confusing what's keyboard interrupt and what is stopping a program or getting a prompt. Confusing.