Skip to content

Commit

Permalink
added pool destructor, addressing #57
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesulf committed Nov 19, 2024
1 parent 16f045a commit 938c0f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to nautilus will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Added an explicit destructor for pool objects to prevent rare freezes.

## [1.0.5] - 2023-10-18

### Added
Expand Down
10 changes: 10 additions & 0 deletions nautilus/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, pool, likelihood=None):
workers.
"""
print("iniating...")
if isinstance(pool, int):
self.pool = Pool(pool, initializer=initialize_worker,
initargs=(likelihood, ))
Expand Down Expand Up @@ -106,3 +107,12 @@ def size(self):
if hasattr(self.pool, attr):
return getattr(self.pool, attr)
raise ValueError('Cannot determine size of pool.')

def __del__(self):
"""
Close the pool.
"""
for attr in ['close', 'shutdown']:
if hasattr(self.pool, attr):
getattr(self.pool, attr)()

0 comments on commit 938c0f6

Please sign in to comment.