-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update Grass7Utils.py. Fixes #20632 #20502 #8557
Conversation
Related to https://issues.qgis.org/issues/20632 This seems to solve this issue, but I don't really know if this change may be introducing some collateral effect. It should be revised by someone with good knowledge of this piece of code.
well that part of code is used to hide the terminal during run popen command in windows context... Are you shure it does fix? "si" is set already just before https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/grass7/Grass7Utils.py#L359 can be "si" modified by the first subprocess call? |
in your test environment, can you monitorize what happen to "si" during it's lifecycle? e.g. just dump it's values before and after the first popen call https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/grass7/Grass7Utils.py#L364 |
I really don't know what is expected to happen to "si", but I saw that during the second call it looked as a vector of size 6 instead of size 3, including the values of the first call. It made me wonder if not being initialized again before the second call could be the reason of the problem. I then only tried this change, and it worked... |
this is a no documented behaviour of subprocess! can you share the values of the vector please? |
The values of the vector are only numerical values that change on every call, they seem to be file descriptor numbers... I suspect they are stdin, stdout, and stderr related... Do you still want me to post their values in a sample execution? |
I suspect that the previous "si" is not the same of the current used due to SIP |
no. here the definition https://github.com/python/cpython/blob/master/Lib/subprocess.py#L164 well... not only at least |
I tested your patch to check if it solves this one https://issues.qgis.org/issues/20502 Processing algorithm… r.external input="D:\MDT\dem_srtm_pttm06_80m.tif" band=1 output="rast_5bfd1e614a4335" --overwrite -o Execution failed after 15.18 seconds Loading resulting layers
So, it seems that it raises this issue https://issues.qgis.org/issues/20244 again, in those algorithms (r.mapcalculator or r.fillnulls). Can you test? |
@PedroVenancio yes happend to all grass algorithm that use v.out or r.out e.g. are compound commands |
@luipir so, this is not completely solved https://issues.qgis.org/issues/20244 right ? |
@PedroVenancio btw, charset can be an error due the lack of: |
Sorry... I was very imprecise... The vectors are in si.lpAttributeList['handle_list']
Here are the screenshots while debugging the second call, hope it helps: |
@luipir I confirm that adding the charset encoding="cp{}".format(Grass7Utils.getWindowsCodePage()) if isWindows() else None, to the second call, they work perfectly! So, it seems that this and @juanmpd changes are needed to solve both issues (https://issues.qgis.org/issues/20502 and https://issues.qgis.org/issues/20632). Completes also this one https://issues.qgis.org/issues/20244. |
Nice work team! |
There might be still an issue - see comments on b39e5a0. |
@juanmpd great... so in few word! never reuse startupinfo after a subprocess call (old handler remain in handle_list). There is no relation with SIP problems. @juanmpd can you add the would be fine
whait for the update of this PR to merge... and I agree with @nyalldawson great team work! |
@PedroVenancio after PR update I'll modify the PR title to close automatically these issues when merged |
if isWindows(): | ||
si = subprocess.STARTUPINFO() | ||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW | ||
si.wShowWindow = subprocess.SW_HIDE | ||
with subprocess.Popen( |
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.
please add also:
encoding="cp{}".format(Grass7Utils.getWindowsCodePage()) if isWindows() else None,
call parameter
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 add this lines later, now I'm busy with another thing..
You requested "add unit test to the failing algorithms (eg. the compound ones)" and "do also a backport PR to 3.4"... I'm sorry, I just joined github today, and I don't know at all what this unit tests or backport are all about... I don't feel I will be able to do this...
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 don't feel I will be able to do this...
np, wait only the add encoding parameter, tnx for the fix
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've already added the line... or at least I think so... :(
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.
If you need anything more from me, please tell me. As I said, I'm not used to github, and I don't know if there is something more that I should have done...
we may update the code later after creationof |
wait for an happy travis to merge |
mmm... sorry for my complete ignorance... It's me who is supposed to do a merge? |
no... wait for the Continuous Integration system (in our case Travis) that run all unit test on every PR to check if it break something! |
Do you make the backport to 3.4.x? |
in this case, I suppose @nyalldawson does "massive" cherry-picks of backportable fixes (if properly labeled) |
Sorry... just to be sure... @nyalldawson is supposed to do "massive" cherry-picks of backportable fixes such as the one in this issue, even if the issue appears as closed? |
I'm not "supposed" to do anything (ie. it's not my job or responsibility to do this!) 😉 But... I DO tend to pick up and backport small fixes like this if the original committer hasn't done it yet and I'm backporting other stuff, just because I want to see 3.4 as a nice stable release and I realise that it's often hard to initially understand the repo structure and the correct process for backporting. In this case I've already backported as 0c36b90 , so it will be part of 3.4.3 |
Thank you very much for your feedback! |
my fault sorry |
^^ that was firmly "tongue in cheek"! |
Related to https://issues.qgis.org/issues/20632
This seems to solve this issue, but I don't really know if this change may be introducing some collateral effect. It should be revised by someone with good knowledge of this piece of code.