You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following script is generated by AI Agent to help reproduce the issue:
# docetl/reproduce.pyimportthreadingimporttimefromconcurrent.futuresimportThreadPoolExecutorclassMockPipeline:
def__init__(self):
self.stop_event=threading.Event()
self.executor=ThreadPoolExecutor(max_workers=2)
defcode_map_operation(self):
defmock_task():
whilenotself.stop_event.is_set():
time.sleep(0.1) # Simulate workreturn"Task Stopped"futures= [self.executor.submit(mock_task) for_inrange(2)]
returnfuturesdefcheck_if_tasks_running(self, futures):
forfutureinfutures:
ifnotfuture.done():
returnTruereturnFalsedefstop_pipeline(self):
self.stop_event.set()
self.executor.shutdown(wait=False)
deftest_stop_pipeline():
pipeline=MockPipeline()
futures=pipeline.code_map_operation()
time.sleep(1) # Let the tasks run for a whilepipeline.stop_pipeline() # Attempt to stop the pipelinetasks_running=pipeline.check_if_tasks_running(futures)
iftasks_running:
raiseAssertionError("Tasks are still running after attempting to stop the pipeline")
try:
forfutureinfutures:
result=future.result(timeout=1) # This should raise an exception if the tasks don't stopassertresult=="Task Stopped"print("Test passed successfully with no errors!")
exceptExceptionase:
raiseAssertionError(e)
if__name__=="__main__":
test_stop_pipeline()
How to run:
python3 docetl/reproduce.py
Expected Result:
Traceback (most recent call last):
File "docetl/reproduce.py", line 49, in <module>
test_stop_pipeline()
File "docetl/reproduce.py", line 38, in test_stop_pipeline
raise AssertionError("Tasks are still running after attempting to stop the pipeline")
AssertionError: Tasks are still running after attempting to stop the pipeline
Thank you for your valuable contribution to this project and we appreciate your feedback! Please respond with an emoji if you find this script helpful. Feel free to comment below if any improvements are needed.
The text was updated successfully, but these errors were encountered: