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

Add psycopg3 support to runmailer_pg #177

Merged
merged 2 commits into from
May 22, 2024
Merged

Add psycopg3 support to runmailer_pg #177

merged 2 commits into from
May 22, 2024

Conversation

jsmits
Copy link
Contributor

@jsmits jsmits commented May 9, 2024

Changes proposed in this PR:

  • Add psycopg3 support to runmailer_pg and gracefully exit on SIGINT

Tips for an ideal PR

@spookylukey
Copy link
Contributor

Hi @jsmits thanks for the PR.

Could you give me some context and a high level description about what is going on here? Thanks!

@jsmits
Copy link
Contributor Author

jsmits commented May 9, 2024

Hi @jsmits thanks for the PR.

Could you give me some context and a high level description about what is going on here? Thanks!

Sure, no problem. I tried to run the runmailer_pg command in my latest django project and it crashed because my project uses psycopg3. Runmailer_pg expects psycopg2 still. This PR makes it seamlessly run with both, so if you have psycopg3 installed, it will use that, and if you have pscyopg2 installed, it will use that, just like it did before. Probably other people will run into this as well when they start using django with psycopg3 and the current django-mailer’s runmailer_pg.

@spookylukey
Copy link
Contributor

Can you explain why this isn't just case of changing imports? Specifically what is different in psycopg3 that requires changes? Thanks!

@jsmits
Copy link
Contributor Author

jsmits commented May 9, 2024

Can you explain why this isn't just case of changing imports? Specifically what is different in psycopg3 that requires changes? Thanks!

Basically two things:

  • connection.poll() is not there anymore in psycopg3; instead you can consume its connection.notifies() generator, which I did
  • psycopg3 does the autocommit part differently, the way psycopg2 did it doesn’t work anymore for psycopg3, that’s why just changing an import doesn’t work for this

@spookylukey spookylukey merged commit 8669999 into pinax:master May 22, 2024
11 checks passed
@spookylukey
Copy link
Contributor

Great, thank you!

@spookylukey
Copy link
Contributor

Released just now in 2.3.2

@jsmits
Copy link
Contributor Author

jsmits commented May 22, 2024

Awesome, thanks a lot!

@jsmits jsmits deleted the support-psycopg3 branch May 22, 2024 20:53
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.

2 participants