包装函数,将结果放入队列
(process_instance_func, instance, metadata, use_mp, max_retries, queue)
| 112 | |
| 113 | return pd.DataFrame(new_dataset) |
| 114 | def _process_and_queue(process_instance_func, instance, metadata, use_mp, max_retries, queue): |
| 115 | """包装函数,将结果放入队列""" |
| 116 | try: |
| 117 | result = _process_instance_wrapper( |
| 118 | process_instance_func, instance, metadata, use_mp, max_retries |
| 119 | ) |
| 120 | queue.put(result) |
| 121 | except Exception as e: |
| 122 | print(f"Error processing instance {instance.get('instance_id', 'unknown')}: {str(e)}") |
| 123 | traceback.print_exc() |
| 124 | # 在发生错误时也要把错误结果放入队列,避免主进程等待 |
| 125 | queue.put(None) # 或者放入一个表示错误的特殊值 |
| 126 | # finally: |
| 127 | # # 确保子进程中的资源被释放 |
| 128 | # queue.close() |
| 129 | |
| 130 | def run_evaluation( |
| 131 | dataset: pd.DataFrame, |
nothing calls this directly
no test coverage detected