Will H
04/03/2024, 2:53 PMMarvin
04/03/2024, 2:53 PMpyppeteer
asynchronously within a task. This particular error occurs because Python's signal
module does not allow setting new signal handlers outside the main thread, and pyppeteer
attempts to set a SIGINT
handler when it is launched.
Here’s a relevant GitHub issue from the pyppeteer
repository that discusses a similar error: Can't run pyppeteer with Threads? - ValueError: signal only works in main thread of the main interpreter. The issue suggests that the use of threads in conjunction with pyppeteer
can lead to this error.
There isn't a direct solution from the Prefect documentation available at the moment, but a common workaround for issues like this involves running the offending code in a separate process rather than in a thread. You might consider using Python’s multiprocessing
module or run the pyppeteer
code within a dedicated executor using concurrent.futures.ProcessPoolExecutor
to avoid clashes with signal handling in the main thread.
Please check the linked GitHub issue for more context, and you may want to consider looking into process-based parallelism or the proper use of asynchronous and synchronous code in Prefect tasks to resolve the issue you're facing.Nate
04/03/2024, 3:05 PMNate
04/03/2024, 3:06 PM