fix(browsers): Close pages that give error
This was causing the browser and the whole code to stand still.
This commit is contained in:
@@ -158,6 +158,8 @@ class DynamicSession(SyncSession, DynamicSessionMixin):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
page_info.mark_error()
|
page_info.mark_error()
|
||||||
|
page_info.page.close()
|
||||||
|
self.page_pool.pages.remove(page_info)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
@@ -298,4 +300,6 @@ class AsyncDynamicSession(AsyncSession, DynamicSessionMixin):
|
|||||||
|
|
||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
page_info.mark_error()
|
page_info.mark_error()
|
||||||
|
await page_info.page.close()
|
||||||
|
self.page_pool.pages.remove(page_info)
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
@@ -250,6 +250,8 @@ class StealthySession(SyncSession, StealthySessionMixin):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
page_info.mark_error()
|
page_info.mark_error()
|
||||||
|
page_info.page.close()
|
||||||
|
self.page_pool.pages.remove(page_info)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
@@ -467,4 +469,6 @@ class AsyncStealthySession(AsyncSession, StealthySessionMixin):
|
|||||||
|
|
||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
page_info.mark_error()
|
page_info.mark_error()
|
||||||
|
await page_info.page.close()
|
||||||
|
self.page_pool.pages.remove(page_info)
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
"""Crawler engine that orchestrates the crawling process."""
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
|
|||||||
Reference in New Issue
Block a user