Conversation
qcodes/utils/multiprocessing.py
Outdated
| try: | ||
| # the only way you'll get a response without asking for one | ||
| # is if we don't understand the query type code | ||
| self._response_queue.put((RESPONSE_ERROR, error_str)) |
There was a problem hiding this comment.
I think it is dangerous (or at least annoying) to put something in the return queue if the user doesn't expect it. Granted, if the user uses QUERY_WRITE then there is no problem, but I see mysef making the typo WIRTE [sic] which would lead to quite annoying situations.
I also see that there is no solution to this as the opposite solution will cause problems when the user types AKS [sic].
When I write my servers in python I use the convention that every command returns something. In the case of a write command, the return could just be OK.
Then I can envision problems with multiprocessing as you don't want to wait for your write to finish before continuing to the next command, but I guess that there is always a moment that you want to make sure that the WRITE command executed well, and that would be the time to check what is in your return_queue.
bottom line: I don't like the Write command a lot. but I would like to see the error handeling make an explicit case for a code_value error:
if code == QUERY_WRITE:
logging.error(error_str)
elif code == QUERY_ASK:
self._response_queue.put((RESPONSE_ERROR, error_str))
else:
logging.error(error_str)
self._response_queue.put((RESPONSE_ERROR, error_str))thereby You are posting the error double, but you are sure the user will actually see the error some way or the other
There was a problem hiding this comment.
That's a good idea, double-posting if the mode is unclear. Granted, these codes are constants, not strings - well, the constants are strings... but if you use them as constants, typos will appear while you're coding rather than at run time.
You're right to be wary of write - there's really only one place I strongly prefer it, and that's posting data from a Loop to the DataServer. In that case I really don't even want to wait for confirmation that the write has happened, because the DataServer could be doing other long-running things like writing a data file, or syncing to a live plot, and we don't want that to slow down the Loop. But if we want to have other commands happen in a non-blocking way we could certainly make a third mode, QUERY_CONFIRMED_WRITE or something, that would acknowledge receipt after it parsed the basic structure of the query but before acting on it.
|
Reading this code, I get quite confused. (this is not specific to this pull request, but If I am to look at this code, I need a bit better understanding) While reading the code I get confused which thread is containing which classes. similarly the From the code it very hard to see now, that QcodesProcess will behave according to the server_class argument passed in ServerManager. tl;dr |
|
Now for some annoying suggestions (sorry :( ) I don't find the name This would make the hierargy of the classes a bit more clear. An |
Yes, that makes sense.
Yep, that would be much cleaner too, I will try to do this. It only exists because I was originally using the instrument class itself as the remote, but as the remote is now a separate dedicated class it is unnecessary and confusing. |
|
@alexcjohnson , Then I will wait with continuing looking at this code until you make these changes, and then go through it again. I think |
abort button is quiet, qc.halt_bg() is loud
| forcibly terminating | ||
|
|
||
| traceback: (default True) whether to print a traceback at the point | ||
| of interrupt, for debugging purposes |
There was a problem hiding this comment.
@MerlinSmiles re #178 - plain qc.halt_bg(), if you enter this in a cell, will only wait max 5 sec, and try to print a traceback (into the subprocess widget, if you're in a notebook). But the abort button in the subprocess widget (here) will wait longer (for whatever get() or set() is happening to finish and leave the system in a clean state) and not print any traceback.
|
@alexcjohnson |
qcodes/instrument/remote.py
Outdated
| manager.connect(self, instrument_class, args, kwargs) | ||
| self._server_name = server_name | ||
| self._shared_kwargs = shared_kwargs | ||
| self._manager = get_instrument_server(self._server_name, |
There was a problem hiding this comment.
@alexcjohnson looking at this line of code,
self._manager = get_instrument_server(self._server_name,
is this really the manager?
then get_instrument_server maybe be ``get_instrument_server_manager ?
There was a problem hiding this comment.
yes, that was a sloppy name :)
|
@damazter I think I've addressed all your comments, want to take another look? Since I had already made so many changes to |
I have not read the entire PR, but is the subprocess monitor the |
There are two safeguards against this (which are not new in this PR, they've been there since I made the
|
|
I can still mess the halt things up. But that was only once out of 10 times. |
Interesting... I can also get some horrible things to happen by pressing the stop button while pyqtgraph is open (even if no plots are open but pyqtgraph has been called in the past). Perhaps we could find a way to have pyqtgraph processes also ignore Anyway, this symptom is the same on master and on this branch, can we get this merged and then troubleshoot that separately? |
|
Yes, sure. Not sure if I should send the 💃 if thats the case, here you have it :) |
|
Thanks @MerlinSmiles |
Taking care of the last 2 points in #136 to make a more robust server architecture:
BaseServerclass that all the servers inherit from, so we have a unified, well-tested pair of pathways foraskandwritequeries.ServerManagermethodsaskorwrite, and these methods encode into the query which flavor it is, invoking the appropriate processor on the other end:askwill reply with the handler's return value,writeputs nothing on the queue.error_queueanymore, the response (toaskonly -writenever responds) just indicates whether it is valid or an error and is handled accordingly.writequeries report their errors locally (usinglogging), rather than to the server's response queue. While this might make these errors less visible because they will never bubble up to the main process, it means these errors get reported faster (you will see them in the subprocess monitor right away) and it relieves potential confusion in that the next query after the error occurs will be the one to throw the error, even though that next query is likely not a problem itself.This is all kind of low level so I'm not sure who's interested in looking through it ( @guenp ? @spauka ? @AdriaanRol ? @damazter ?) , but it makes me a lot happier anyway about deleting the timeout in #144