-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implementation of the API queue #374
Conversation
see my commit here: b84f34e which resolves a situation where the first queue (
|
First Problem Solution Second Problem Solution |
b1c5bcf
to
6c28cbf
Compare
So recap: The problem here was that we could not make an api call from a |
Third Problem
Solution Fourth Problem
The problem is still be investigated and debugged. |
…SQLAlchemy objects Currently we have managed to avoid threading issues with SQLA. Passing a Session or Model (object corresponding to a DB row) across thread boundaries is dangerous and will raise exception. We have managed to avoid problems with this so far because most of our objects live in the main GUI thread. Additionally, our signal/slot connections all live in the main thread, and when they don't, we might actually still be triggering actions in the main thread because we're not using a Qt.QueuedConnection when we connect them. This commit attempt to give objects their own session_maker so they can create sessions on demand and fetch thread-local objects from the DB.
Follow-up issuesThese are issues that we can address outside of this PR, mentioned in the description |
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.
this looks great to me, just a couple notes inline
Checkpoint There are the following 7 more broken tests and some missing test coverage for this PR, in case someone in a different timezone wants to work on this with me. Current test coverage (lowest percentage is 84% for
Please just push frequently. I'll probably be back online in a few hours, but maybe not until tomorrow morning. |
A couple bugs that need to be fixed:
|
NoteNeed to document what ETag is all about, this could be addressed when working on this issue: #383 See log:
|
@creviera
This is #361 I think. |
This is a bug in |
@heartsucker - I see the issues happening on |
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.
my comments were also addressed, lgtm!
Fixes #224
Adds the initial implementation of the
ApiJobQueue
. This diverged a bit from the original design spec, but still fundamentally accomplishes the task of strict ordering of replies. This PR only containsApiJob
s for downloading files from the API, but using the patterns here, the rest should be relatively easy to implement.Design Choices
An
ApiJob
only needs to implement one method calledcall_api
that should do everything needed to process an API including writing it to the local DB. This method might be renamedrun_job
for clarity.On success/failure, respective signals are emitted. These are connected to callbacks on the
Controller
which then takes action directly and possible relays the signal to otherQObjects
. In the case of aDownloadSubmissionJob
, we don't want to directly connect theFileWidget
s to the signals on the job because that is likely too much connectedness. Using theController
as a relay helps maintain separation.Follow Ups
There's a few tickets we'll need to add to polish this up. Addressing all of these would require too much time and already this PR is fairly large and complex.
Timeout / No Auth
There is no signal for for
ApiInacessibleError
orRequestTimeoutError
, and there needs to be as these being raised requires action from the user. As it stands now, either of these errors will either abort the thread (with no way to restart) or crash the app. I haven't tested.Restarting Threads
If a thread aborts because it has no auth or timeout, there needs to be a way to restart it. Likely this would mean calling
ApiJobQueue.start_queues()
again, but as it's written now, this wouldn't restart the current threads but it would create new ones (or do some other badness).