1 场景复现
相关工具及版本:
fastapi==0.95.0
trafilatura==1.5.0
python==3.10
使用FastAPI开发获取URL内容的接口:
抛出的异常如下:
File “/app/src/utils/file_process_util.py”, line 66, in request_data_from_url
text = trafilatura.extract(source_data)
File “/usr/local/lib/python3.10/site-packages/trafilatura/core.py”, line 1050, in extract
signal(SIGALRM, timeout_handler)
File “/usr/local/lib/python3.10/signal.py”, line 56, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter