Repository navigation
Signal Module Error in PythonCoderTool During RL Training #30
Description
Activity
Hi xixi!
Many thanks for your raised bug.
@Zhuofeng-Li Consider refine tool
Python_Coderfurther.If there's any other issue found in our repo, please feel free to info us!
Reacted by zhangxixi551 and Pan LuReacted by zhangxixi551No problem!
Reacted by zhangxixi551Reacted by zhangxixi551Hi @zhangxixi551, We’ve pushed a new hotfix in #PR 31. It’s not yet validated on training runs. If you happen to test it and share your feedback, that would be greatly appreciated and should help us decide on merging.
Reacted by zhangxixi551Reacted by zhangxixi551Hi @zhangxixi551, We’ve pushed a new hotfix in #PR 31. It’s not yet validated on training runs. If you happen to test it and share your feedback, that would be greatly appreciated and should help us decide on merging.
I am very grateful for the author's reply and code modifications!
However, after recent testing, I found that your defined
@contextmanager def timeout(seconds): ...
cannot effectively terminate Python code that has exceeded its time limit because:Exceptions thrown by
threading.Timercannot interrupt the running main thread code.Specifically:
The Timer thread runs in the background:
threading.Timerwill executeraise_timeout()in another thread (Thread-1) after the time limit is exceeded.Exceptions cannot propagate across threads: A
TimeoutExceptionthrown in Thread-1 will not affectexec(execution_code)currently executing in the main thread.The main thread's
exec()will continue to run until completion (even if the time limit has exceeded).非常感激作者的回信以及对代码的修改!
不过我最近经过测试后发现,您定义的
@contextmanager
def timeout(seconds):
...
无法有效终止已超出时间限制的python code,原因是:
threading.Timer 抛出的异常不能中断正在运行的主线程代码。具体来说:
Timer线程在后台运行:threading.Timer 会在超出时间限制后在另一个线程(Thread-1)中执行raise_timeout()
异常无法跨线程传播:在Thread-1中抛出的TimeoutException不会影响主线程中正在执行的exec(execution_code)
主线程的 exec() 会继续运行直到完成(即使已经超出时间限制)Reacted by zhangxixi551Thank you very much for the update! We really appreciate it.
We are currently working on resolving the timeout termination issue related to the thread chaining. We’ll keep you posted as we make progress.
Reacted by zhangxixi551 and Pan LuReacted by zhangxixi551 and Pan LuThank you very much for the update! We really appreciate it.
We are currently working on resolving the timeout termination issue related to the thread chaining. We’ll keep you posted as we make progress.
I am so grateful to receive your reply! I look forward to it!
Reacted by zhangxixi551
During our RL training, the following error occurred:
(AgentLoopWorker pid=8803) ERROR:2026-01-21 22:59:59,285:Error executing code: signal only works in main thread of the main interpreter
Root Cause: This error is caused by the use of Python's signal module in PythonCoderTool (e.g., signal.alarm(0)). Python's signal.signal() function can only be called in the main thread of the main interpreter, which leads to this error.
我们在进行RL训练时,出现如下报错:
(AgentLoopWorker pid=8803) ERROR:2026-01-21 22:59:59,285:Error executing code: signal only works in main thread of the main interpreter
【报错原因】因 PythonCoderTool 中使用了Python的signal模块(例如signal.alarm(0)),而Python的signal.signal() 函数只能在主线程的主解释器中调用。因此导致报错。