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

[FIX] Register __del__ method of TwinModel to avoid issue atexit #116

Merged
merged 18 commits into from
Sep 19, 2023

Conversation

lboucin
Copy link
Collaborator

@lboucin lboucin commented Sep 8, 2023

@chrpetre The error raised at the end of the example script execution was due to python interpreter calling the cleanup method register to atexit module in the pytwin.settings module before to call the del method of the TwinModel.

There was no issue if the example business logic is encapsulated into a main method and the main method called at the end of the script. I think this due to the order in which methods are registered by the interpreter, which follow a last in, last out pattern at process exit.

The solution I found is to explicitly register the del method of TwinModel object to the atexit module. When importing pytwin, the init.py script in called, and then the registration of the del method is done after the registration of the settings.cleanup_temp_pytwin_working_directory method, which should avoid it to try deleting log file of the runtime of the TwinModel before it to be closed.

@github-actions github-actions bot added the bug Something isn't working label Sep 8, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2023

Codecov Report

Merging #116 (64406aa) into main (6b860f5) will decrease coverage by 0.19%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
- Coverage   89.04%   88.86%   -0.19%     
==========================================
  Files          11       11              
  Lines        2336     2334       -2     
==========================================
- Hits         2080     2074       -6     
- Misses        256      260       +4     

@lboucin lboucin changed the title FIX Register __del__ method of TwinModel to avoid issue atexit [FIX] Register __del__ method of TwinModel to avoid issue atexit Sep 19, 2023
Copy link
Collaborator

@chrpetre chrpetre left a comment

Choose a reason for hiding this comment

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

thanks Lucas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants