我正在从 POST 请求中调用py_trees.trees.BehaviourTree()的setup()方法(这会将我转移到非主线程),但出现以下错误:
ValueError: signal only works in main thread
如何在不传输主线程中的setup()方法的情况下处理这个问题?
此处提供了完整的跟踪:
File "/usr/src/***/***/***/behavior_trees/tree.py", line 40, in test_tree
behaviour_tree.setup(timeout=15.0)
│ └ <function BehaviourTree.setup at 0x7f59a7feb3a0>
└ <py_trees.trees.BehaviourTree object at 0x7f59a4068d60>
File "/usr/local/lib/python3.8/site-packages/py_trees/trees.py", line 324, in setup
setup(
└ <function setup at 0x7f59a7fe3280>
File "/usr/local/lib/python3.8/site-packages/py_trees/trees.py", line 109, in setup
signal.signal(
│ └ <function signal at 0x7f59b537e3a0>
└ <module 'signal' from '/usr/local/lib/python3.8/signal.py'>
File "/usr/local/lib/python3.8/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
│ │ │ │ │ └ functools.partial(<function setup.<locals>.signal_handler at 0x7f59a40d9ca0>, original_signal_handler=<Handlers.SIG_DFL: 0>)
│ │ │ │ └ <function _enum_to_int at 0x7f59b537e310>
│ │ │ └ <Signals.SIGUSR1: 10>
│ │ └ <function _enum_to_int at 0x7f59b537e310>
│ └ <built-in function signal>
└ <module '_signal' (built-in)>
ValueError: signal only works in main thread