requests-html throwing error RuntimeError: There is no current event loop in thread 'Thread-1 (worker)' when using ThreadPool

Author: muaaz-ur-habibiCreated Jun 13, 2025Updated Jun 13, 2025

trying to multithread scraping a bunch of urls with requests-html

but it isnt exactly working

any idea how to fix this?

def get_dynamic_content(url_obj:URLObject, req_parameters_obj:RequestParameters): reqh = HTMLSession() if url_obj.request_type == "get": r = reqh.get(url_obj.url) r.html.render() reqh.close() return r.html

when i try to run this in threaded version

tpool = ThreadPool(processes=int(config_data['max thread count']))

def start_scraping(): out = tpool.map(get_dynamic_content, toscrape) tpool.close() tpool.join() print(out)

it just throws the mentioned error

is there any fix?