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

Replace sync_to_async with database_sync_to_async #356

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

smk4664
Copy link
Contributor

@smk4664 smk4664 commented Dec 20, 2024

This change allows the Slack Socket Mode to properly close and reopen the database connection when finished processing a command.

Closes: #355

What's Changed

This PR introduces Channels.db.database_sync_to_async to resolve issue where the Asynchronous thread does not properly close and reopen database connections. This does not require adding Channels to the INSTALLED_APPS in nautobot_config.py, nor does it require replacing the uwsgi worker like the Channels installation page shows.

To Do

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

This change allows the Slack Socket Mode to properly close and reopen the database connection when finished processing a command.
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Is there anything straightforward that can be added for unit/integration test coverage here or is it complex enough to remain in the realm of manual testing only for now?

Removes the bulk of having Channels installed when no functionality from the app aside from this command is being used.
@smk4664
Copy link
Contributor Author

smk4664 commented Dec 20, 2024

Is there anything straightforward that can be added for unit/integration test coverage here or is it complex enough to remain in the realm of manual testing only for now?

I believe this will be hard to recreate in tests. From what I have read, this is a safe change to do, and is built-in to Django.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slack Socket mode does not auto-reconnect to MySQL
2 participants