-
Notifications
You must be signed in to change notification settings - Fork 28
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
login_required(doConnectionCleanup=False) will close conn unless streaming #191
login_required(doConnectionCleanup=False) will close conn unless streaming #191
Conversation
My preference is the original style. Yes, if you have set |
If you wish to prevent cleanup, you can still set All that this PR does is prevent It sounds easy to call |
I understand what the PR does and I appreciate it may make it easier to do the right thing for your use case. However, I don't agree that hiding connection semantics behind response class type checks makes these sorts of scenarios easier to not screw up overall. It is now just as easy to have changes in your response class hierarchy cause a scenario where you do not get your expected behaviour and then encourages people to use |
bf74f03
to
85e33b3
Compare
Hi, Apologies - This was a bit of a last-minute PR before I was away for 2 weeks... Having revisited these changes, I realise that the removal of Previously with the use of Re #191 (comment): If |
Of course it would. My point is that there is inherent complexity here and it's not good design to pretend that there isn't. Stating Trading one set of complexity (return values) for another (class hierarchy) is just that. One is better in certain circumstances, one is better in others. One is not objectively better universally. If you want to discuss making connection handling easier in streaming response cases more widely there are lots of ways to approach that. Likely better ones than return values or class hierarchy checks. Django, our use of it, and our experience has evolved a lot in the 8 years since this code was added. We are now conflating a fundamental platform and design change in this PR with real, useful, and desired functionality from #192. The changes in #192 do not require the changes from this PR in order to be implemented and should be proposed utilizing the style already established. |
…ingHttpResponse Use doConnectionCleanup as statement of intent
We want the dev Exception not to get ignored
Briefly discussed during standup. It might be worth looking into whether https://github.com/ome/omero-weberror can simply be extended to simplify the testing of the new functionality/contract introduced by this PR. |
Added tests without using weberror. See ome/openmicroscopy#6248 |
Looks like this may well need the test fix from ome/devspace#169 |
I suspect we'll need to review all places where |
Travis is failing with:
But that file doesn't contain |
Hmmm - the 'Details' link above goes to https://travis-ci.org/github/ome/omero-web/builds/719232030 which is for commit 1d0e394 which isn't right. |
So, travis seems to be merging each commit into ba64516 before running flake8, which is then failing. |
…les_ConnCleaningHttpResponse
👍 |
This PR ensures that when you to use
@login_required(doConnectionCleanup=False)
decorator (for methods that return aConnCleaningHttpResponse
to stream data from OMERO), if you return any other responses (e.g.Http404
or other page that doesn't need to stream from OMERO), then the@login_required
decorator will callconn.close()
for you.If you previously needed to use
@login_required(doConnectionCleanup=False)
, but ended up returning aHttp404
then the connection wouldn't not get closed.This also allows you to be more flexible and your view methods can return either a Streaming HttpResponse OR a standard HttpResponse. Previously, if you wanted to also return a non-streaming response from the same view method then you needed to make sure you called
conn.close()
manually.I needed this logic for another PR (coming soon on top of this commit).
Testing:
handlerInternalError()
) - check conn is closed in logs for both.cc @chris-allan