perf(session): improve page management and speed up execution
Close pages immediately after tasks finish to reduce resource usage and improve overall performance. Update corresponding test files to reflect the new page lifecycle management.
This commit is contained in:
@@ -381,8 +381,9 @@ class StealthySession(StealthySessionMixin, SyncSession):
|
||||
page_info.page, first_response, final_response, params.selector_config
|
||||
)
|
||||
|
||||
# Mark the page as finished for next use
|
||||
page_info.mark_finished()
|
||||
# Close the page, to free up resources
|
||||
page_info.page.close()
|
||||
self.page_pool.pages.remove(page_info)
|
||||
|
||||
return response
|
||||
|
||||
@@ -701,8 +702,9 @@ class AsyncStealthySession(StealthySessionMixin, AsyncSession):
|
||||
page_info.page, first_response, final_response, params.selector_config
|
||||
)
|
||||
|
||||
# Mark the page as finished for next use
|
||||
page_info.mark_finished()
|
||||
# Close the page, to free up resources
|
||||
await page_info.page.close()
|
||||
self.page_pool.pages.remove(page_info)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user