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

Avoid calling cleanup from destructor #168

Merged
merged 3 commits into from
May 16, 2024
Merged

Conversation

ferdonline
Copy link
Collaborator

Context

Neurodamus used to ensure cleanup was called by calling it from the destructor of the Neurodamus class.

However, depending on the python version, this could lead to crashes as some objects from Node eventually were already destroyed.

To workaround this problem, at some point we introduced the cleanup_atexit parameter which would skip over this procedure, and notably multiscale_run was using it. However this was not a solution as cleanup was not being called.

Scope

This PR fixes this long standing issue. Cleanup is now called directly from the top-level run() function. It can still be avoided if the user really wants to keep the data, with the parameter cleanup=False

Testing

CI is happy.

Review

  • PR description is complete
  • Coding style (imports, function length, New functions, classes or files) are good

@ferdonline ferdonline requested review from WeinaJi and jorblancoa May 8, 2024 13:45
@ferdonline ferdonline mentioned this pull request May 8, 2024
4 tasks
@bbpbuildbot

This comment has been minimized.

WeinaJi
WeinaJi previously approved these changes May 8, 2024
Copy link
Collaborator

@WeinaJi WeinaJi left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!
@cattabiani Once this change is deployed, in multiscale_run you will have to remove cleanup_atexit from calling neurodamus.

@WeinaJi WeinaJi force-pushed the enh/leite/no-cleanup-in-dtor branch from b4fd6ae to a636f3d Compare May 10, 2024 07:35
@bbpbuildbot

This comment has been minimized.

@WeinaJi
Copy link
Collaborator

WeinaJi commented May 13, 2024

Shall we merge this PR ?

@jorblancoa
Copy link
Collaborator

Shall we merge this PR ?

Looks good to me!

@jorblancoa jorblancoa force-pushed the enh/leite/no-cleanup-in-dtor branch from a636f3d to a541267 Compare May 13, 2024 14:02
@bbpbuildbot

This comment has been minimized.

jorblancoa
jorblancoa previously approved these changes May 15, 2024
@bbpbuildbot

This comment has been minimized.

@ferdonline
Copy link
Collaborator Author

Tests just failed because pytest-forked depends on py.process which went away. pytest-dev/pytest-forked#88

@ferdonline ferdonline dismissed stale reviews from jorblancoa and WeinaJi via 5c2e841 May 15, 2024 11:59
@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline force-pushed the enh/leite/no-cleanup-in-dtor branch from 5c2e841 to fa58d2e Compare May 15, 2024 14:20
@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline force-pushed the enh/leite/no-cleanup-in-dtor branch 2 times, most recently from 8e1fcb6 to b7856b9 Compare May 15, 2024 14:35
@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline force-pushed the enh/leite/no-cleanup-in-dtor branch from b7856b9 to 5f8f84f Compare May 15, 2024 14:46
@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline force-pushed the enh/leite/no-cleanup-in-dtor branch from 5f8f84f to 5e2fe82 Compare May 15, 2024 15:00
@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline force-pushed the enh/leite/no-cleanup-in-dtor branch 2 times, most recently from 11423ff to be0b856 Compare May 16, 2024 13:43
@bbpbuildbot
Copy link

@ferdonline ferdonline merged commit 827ffd1 into main May 16, 2024
15 checks passed
@ferdonline ferdonline deleted the enh/leite/no-cleanup-in-dtor branch May 16, 2024 15:12
atemerev pushed a commit that referenced this pull request May 24, 2024
## Context
Neurodamus used to ensure `cleanup` was called by calling it from the
destructor of the `Neurodamus` class.

However, depending on the python version, this could lead to crashes as
some objects from `Node` eventually were already destroyed.

To workaround this problem, at some point we introduced the
`cleanup_atexit` parameter which would skip over this procedure, and
notably multiscale_run was using it. However this was not a solution as
cleanup was not being called.

## Scope
This PR fixes this long standing issue. Cleanup is now called directly
from the top-level `run()` function. It can still be avoided if the user
really wants to keep the data, with the parameter `cleanup=False`
 
## Testing
CI is happy.

## Review
* [x] PR description is complete
* [x] Coding style (imports, function length, New functions, classes or
files) are good
WeinaJi pushed a commit that referenced this pull request Oct 14, 2024
## Context
Neurodamus used to ensure `cleanup` was called by calling it from the
destructor of the `Neurodamus` class.

However, depending on the python version, this could lead to crashes as
some objects from `Node` eventually were already destroyed.

To workaround this problem, at some point we introduced the
`cleanup_atexit` parameter which would skip over this procedure, and
notably multiscale_run was using it. However this was not a solution as
cleanup was not being called.

## Scope
This PR fixes this long standing issue. Cleanup is now called directly
from the top-level `run()` function. It can still be avoided if the user
really wants to keep the data, with the parameter `cleanup=False`
 
## Testing
CI is happy.

## Review
* [x] PR description is complete
* [x] Coding style (imports, function length, New functions, classes or
files) are good
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.

4 participants