Skip to content

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

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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