Python, Selenium and Chromedriver - endless loop using find_element_by_id causes CPU problem

前端 未结 2 1709
逝去的感伤
逝去的感伤 2021-01-17 02:22

Good day to all! I\'ve been experiencing this problem for a week now but I don\'t think I can solve it and I also do not see any solution based on articles online. Hopefully

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 03:21

    Have you tried releasing memory into the loop? Maybe by picking up the values (list out of the loop?) and then resetting those variables to None you can avoid excessive memory consumption.

    ...
    while True:
    
    ...
        close1 = close2 = close3 = close4 = close5 = close6 = None
    
    ...
    

    You can also try forcing the garbage collector:

    import gc
    
    while True: 
    ...
        gc.collect()
    

    If you think that the reason may be a script another another solution to detect the problem might be to enable Chrome to do remote debug and debug the page.

    --remote-debugging-port=9222
    

    I hope some of this helps you.

提交回复
热议问题