-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When multi_process=True, the predict method in unimol_tools/data/conformer.py can hang intermittently. The hang occurs when calling MolPredict.predict(); the process stops at pool.imap() with no error output. Memory usage looks normal while the CPU is idle, and the process must be terminated manually.
Root cause analysis:
- Missing pool.join() call: In the two
transform()methods inconformer.py(around lines 191 and 466), the code callspool.close()but never callspool.join(). This can allow the main process to continue before worker processes have finished, causing a race condition. - Insufficient exception handling: An
except:at line 279 catches all exceptions (includingKeyboardInterrupt) and usesprintinstead of a logger to record the error. - No context manager usage: The process pool should be used with a context manager (
with Pool() as pool:) to ensure proper cleanup. - No timeout mechanism:
pool.imap()is used without any timeout handling; if a worker blocks, the main process cannot recover.
unimol_tools Version
0.1.5
Expected behavior
When multi_process=True, multiprocessing should operate reliably and not hang. Specifically:
- All worker processes should finish before the main process continues.
- Exceptions should be logged and handled appropriately.
- Processes should be terminable by signals such as
KeyboardInterrupt. - Long-running or blocking tasks should be handled with timeouts.
To Reproduce
Steps to reproduce:
- Set
multi_process=Trueby default. - Call
MolPredict.predict()again and again. - Observe the process state. Sometimes, calling a ctrl+c would end the process and the process would run again to get the right result.
from unimol_tools import MolPredict
from pathlib import Path
from typing import List
def UniMolPredict(model_dir: Path, csv_path: Path) -> List[float]:
logger.info(f" Start predicting: {csv_path}")
clf = MolPredict(load_model=model_dir)
logger.info(" Prediction model: clf is a MolPredict object")
y_pred = clf.predict(str(csv_path)) # Hangs here
logger.info(f" Prediction result: {y_pred}")
return y_predEnvironment
No response
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working