Skip to content

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

@muaaz-ur-habibi

Description

@muaaz-ur-habibi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions