-
-
Notifications
You must be signed in to change notification settings - Fork 816
Use signals to handle DB-close actions #2179
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
base: main
Are you sure you want to change the base?
Conversation
Hey @sevdog
Postgres is pretty easy to set up in GHA:
Just initial take, I quite sceptical that this is the way forwards. It seems like a sledgehammer to crack a nut. From your comments on the issue, I wondered if just patching at the start of the process, rather than trying to do it in such a narrow context as we are might be more robust.
Crudely, yes, let's try setting a flag and no-oping on that. Does that resolve the issue. (In which case we can think about being more sophisticated.) cc @bigfootjon |
…base consumer class
Thnk you @carltongibson, I understand your concern for the complexity of the implementation. Today I was in the mood of experimenting and I have overdone a bit with the whole context-manager/decorator part. I have tested the current version of this branch with my project and I found that using Let me know what do you think and how do you feel about it. Cause this week I have a couple of days reserved to this task that I am willing to fulfill because I will feel better if I can update |
@sevdog I note this would require us to drop Django 4.2. That might be OK but I'm wondering if there isn't a smaller workaround you could apply. Is there a reliable reproduce, in the test project from the issue maybe? |
Did you mean something like: # this may need to check that the AttributeError is raised from the signal object
try:
await singl.asend(...)
except AttributeError:
await sync_to_async(signal.send)(...) Or something like: import django
...
if django.VERSION >= (5, 0):
await singl.asend(...)
else:
await sync_to_async(signal.send)(...)
I have already added this PR to the test matrix in https://github.com/sevdog/test-websocker-user-lock. I will update the tests after having finishing a change to simplify the handling of disconnect/connect using a mixin to be applied on |
This is a proposal to solve #2118.
I have resurrected the signals which were used in 1.x (in the old worker component) and put them in the consumer and
database_sync_to_async
lifecycle.I added a context-manager in consumer to handle this (yet I feel that it is not the best solution) to disconnect-connect them.
Since #2118 does not get triggered when sqlite is used as DB backend, it need a database which is accessed through a socket, I would like to discuss the best way to put a test against a "real" database in the CI.