-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Eliminate globals usage #2790
base: master
Are you sure you want to change the base?
Eliminate globals usage #2790
Conversation
bb39faa
to
ee417ba
Compare
Would be awesome if you can add this on another PR and base it on this branch/PR #2760
|
thanks again - tests are being a bit flakey, i'll keep pushing and see whats up |
could this run the basic tests in parallel then too? (faster) |
can you branch from this branch and also do that work on another PR? |
Yes, it will take a while because there are many tests and I don't quite understand the test fixture setup yet. I actually have another branch in my local repo where I changed the entire codebase to use Quart, but the change is gigantic. Doing these smaller changes first will help make the transition to asyncio more smooth if you want to go that direction. |
It should be able to using |
f396b13
to
266b879
Compare
amazing :) first question, what is Quart? 'It should be able to using pytest-xdist." that would be neet, also if the |
problem is the architecture of the app, it's basically just a single threaded app because it has this kind of global dictionary of data "datastore" that cant be accessed from different threads if the flask wrapper launched a new thread per request which is why i guess mysql/couchdb/etc exist - tho i initially started this app in the fastest easiest way i could without worrying about huge database setups, i really like the flat JSON way I would really prefer to have a "settings.json" in each "datastore" watch UUID directory rather than in one huge |
Yes, I noticed that JSON files were preferred from looking at the code. Quart is Flask but using For instance, when |
Quart looks amazing, because i'de also like to add some kind of websocket for better live updates too |
@@ -327,7 +316,7 @@ def login(): | |||
|
|||
password = request.form.get('password') | |||
|
|||
if (user.check_password(password)): | |||
if (user.check_password(password, datastore=datastore)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why cant check_password
access the "g
" ? it could be called g.datastore
? then it would mean i can stop passing "datastore" around everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be done that way. I don't like putting globals in because it makes testing problematic. I don't even know how using g
works with tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit, i dont know much about this :) just an idea, yes, agreed
This will help running tests because the app isn't initialized automatically by touching the "changedetectionio" package. Moving things out of the __init__.py removes the side-effect of "import changedetection" which means tests can control the state without restarting. This is the first step in making the tests run with only calling "pytest". The fixture use and test setup need to be adjusted to not depend on test ordering.
This should make the code a little cleaner to use these proxy objects.
heya, whats your thoughts on this PR? as in, how much more work should go into it? what else are you hoping to solve here? |
if functions like this in Watch could access changedetection.io/changedetectionio/model/Watch.py Lines 130 to 140 in feccb18
is it possible? Because "Watch" object cant "see" the global datastore values in the case that it needs to default to some value if the 'watch' is to default/null etc |
Hello, this is a very long PR and it needs to be resolved ASAP or it will get more and more conflicts and probably get closed/lost - i would really love to resolve this |
This will help running tests because the app isn't initialized automatically by touching the "
changedetectionio
" package. Moving things out of the__init__.py
removes the side-effect of "import changedetection
" which means tests can control the state without restarting.This is the first step in making the tests run with only calling "
pytest
". The fixture use and test setup need to be adjusted to not depend on test ordering.