Skip to content
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

clnrest: Import sys in except clause explicitly #6883

Merged

Conversation

nepet
Copy link
Collaborator

@nepet nepet commented Nov 20, 2023

This fixes a crash on startup of core-lightning where gevent could not be imported. This happens before sys is imported and throws us into the except clause which calls sys.
By importing it explicitly in the except clause we are not dependend of the order of imports in the try bracket.

@nepet
Copy link
Collaborator Author

nepet commented Nov 20, 2023

Should we add a check for this?

This fixes a crash on startup of core-lightning where gevent could not
be imported. This happens before sys is imported and throws us into the
except clause which calls sys.
By importing it explicitly in the except clause we are not dependend of
the order of imports in the try bracket.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>

Changelog-Fixes: Plugin: clnrest crashed on startup when gevent was
missing.
@nepet nepet force-pushed the 202311-fix-clnrest-startup-crash branch from 44878ca to 79e9f76 Compare November 20, 2023 15:17
Copy link
Collaborator

@ShahanaFarooqui ShahanaFarooqui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Peter, Thanks for the PR. However moving sys import up in the try block should resolve the issue and will not require two separate imports too (moving line 6 up to line 4).

@nepet
Copy link
Collaborator Author

nepet commented Nov 20, 2023

Moving the sys import up to the top will also resolve the issue but comes with the risk that we forget about this in the future and make the same mistake again. Importing it explicitly removes this risk. Importing a module twice will ignore the second import and just give a reference to the module that has already been imported so this should not add overhead(?).
Let me know if you still want me to change this.

@ShahanaFarooqui
Copy link
Collaborator

ACK 79e9f76.

@nepet nepet merged commit eb3b1b8 into ElementsProject:master Nov 21, 2023
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants