Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Task Clenup - add timeout to browser context close #714

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

ykeremy
Copy link
Contributor

@ykeremy ykeremy commented Aug 22, 2024

🚀 This description was created by Ellipsis for commit b8dc27d

Summary:

Introduced task_cleanup methods and browser context timeout for efficient Chrome process and browser state management, with enhanced error handling and updates across multiple files.

Key points:

  • Introduced task_cleanup methods for Chrome process and browser state management.
  • Added task_cleanup in cloud/agent_functions.py to terminate Chrome processes.
  • Implemented task_cleanup in skyvern/forge/agent_functions.py for browser state handling.
  • Updated skyvern/forge/agent.py to call task_cleanup during send_task_response.
  • Enhanced skyvern/webeye/browser_manager.py to handle TimeoutError during task cleanup.
  • Added BROWSER_CLOSE_TIMEOUT constant in skyvern/constants.py for browser context close timeout.
  • Updated BrowserManager.cleanup_for_task to use asyncio.timeout for closing browser contexts.
  • Added handling for TimeoutError in cleanup_for_task to log a warning if timeout occurs.
  • Integrated cleanup_browser_and_create_artifacts into task_cleanup.
  • Moved Chrome process termination to workers/temporal_workflows.py.

Generated with ❤️ by ellipsis.dev

<!-- ELLIPSIS_HIDDEN -->

| 🚀 | This description was created by [Ellipsis](https://www.ellipsis.dev) for commit 938bc7e21ccda1f5ba8f10f7e290372aa17ed4e6  |
|--------|--------|

### Summary:
Introduced `task_cleanup` methods and browser context timeout for efficient Chrome process and browser state management, with updates across multiple files.

**Key points**:
- Introduced `task_cleanup` methods for Chrome process and browser state management.
- Added `task_cleanup` in `cloud/agent_functions.py` to terminate Chrome processes.
- Implemented `task_cleanup` in `skyvern/forge/agent_functions.py` for browser state handling.
- Updated `skyvern/forge/agent.py` to call `task_cleanup` during `send_task_response`.
- Enhanced `skyvern/webeye/browser_manager.py` to handle `TimeoutError` during task cleanup.
- Added `BROWSER_CLOSE_TIMEOUT` constant in `skyvern/constants.py`.
- Updated `BrowserManager.cleanup_for_task` to use `asyncio.timeout` for closing browser contexts.
- Integrated `cleanup_browser_and_create_artifacts` into `task_cleanup`.
- Moved Chrome process termination to `workers/temporal_workflows.py`.

----
Generated with ❤️ by [ellipsis.dev](https://www.ellipsis.dev)

<!-- ELLIPSIS_HIDDEN -->
@ykeremy ykeremy added the sync label Aug 22, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to b8dc27d in 10 seconds

More details
  • Looked at 58 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_KNZvZepQpCtAo18D


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

LOG.info("Task is cleaned up")
try:
if browser_state_to_close:
async with asyncio.timeout(BROWSER_CLOSE_TIMEOUT):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncio.timeout is incorrect; use asyncio.wait_for instead. This issue is also present in other parts of the code.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on b8dc27d in 21 seconds

More details
  • Looked at 57 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_XWlyfhPDqJEUmg5R


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

LOG.info("Task is cleaned up")
try:
if browser_state_to_close:
async with asyncio.timeout(BROWSER_CLOSE_TIMEOUT):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncio.timeout is not a valid function. Use asyncio.wait_for to apply a timeout to an async operation.

Suggested change
async with asyncio.timeout(BROWSER_CLOSE_TIMEOUT):
async with asyncio.wait_for(BROWSER_CLOSE_TIMEOUT):

@wintonzheng wintonzheng merged commit 43cbfa7 into main Aug 22, 2024
2 checks passed
@wintonzheng wintonzheng deleted the shu/task_cleanup branch August 22, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants