After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 787792 - Race with Python diagnostics and file saving
Race with Python diagnostics and file saving
Status: RESOLVED OBSOLETE
Product: gnome-builder
Classification: Other
Component: plugins
3.26.x
Other Linux
: Normal major
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-17 17:05 UTC by Alexandre Franke
Modified: 2018-01-11 10:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
unsaved-files: replace temp files atomically (1.93 KB, patch)
2017-09-17 18:37 UTC, Christian Hergert
committed Details | Review

Description Alexandre Franke 2017-09-17 17:05:36 UTC
Open a file that does not comply with PEP-8, go to a line that shows a light bulb, quickly fix the (e.g. spacing around operator) issue and save. All lightbulbs disappear from the gutter, a new one appears at the top of the file and the tooltip claims the there is no such file 'something/something/buffer.py'.

The only way to get back to the list of lightbulbs to continue fixing your code is to close and reopen the file.
Comment 1 Christian Hergert 2017-09-17 18:27:16 UTC
Those checks are performed by gnome-code-assistance. So there is a chance the issue is there.

But upon investigating, I see we just use g_file_set_contents() in libide/buffers/ide-unsaved-files.c to save the temporary files (which are used to communicate with G-C-A).

Perhaps we need to change that code to write a secondary temp file and then rename() over the previous file.
Comment 2 Christian Hergert 2017-09-17 18:37:12 UTC
Created attachment 359940 [details] [review]
unsaved-files: replace temp files atomically
Comment 3 Christian Hergert 2017-09-17 18:38:47 UTC
Comment on attachment 359940 [details] [review]
unsaved-files: replace temp files atomically

I suspect this will fix it. Let me know or close appropriately.

Attachment 359940 [details] pushed as a6ba90f - unsaved-files: replace temp files atomically
Comment 4 Alexandre Franke 2017-09-17 20:48:06 UTC
That doesn't seem to be enough, the problem is still present.
Comment 5 Christian Hergert 2017-09-17 21:08:54 UTC
Then I'm inclined to think it is a bug in G-C-A and not Builder.
Comment 6 Elad Alfassa 2017-10-20 19:48:47 UTC
Maybe this happens because the G-C-A python backend opens the file 3 time? one time for using the python AST to check for syntax errors, one time when invoking pep8, and one time when invoking pylint.

Builder deletes the temp file after the buffer is saved, right?
So it could be that Builder asks G-C-A to parse the file, and then while it's parsing the user hits ctrl+s and the temp file is deleted, and then G-C-A gets to calling pep8 or pylint, and the file is no longer there, so it returns an error.

If I'm correct, there are three ways we can fix this:

1) We could make G-C-A copy the temp file it gets to another temp file, to make sure it doesn't disappear (modifying it to only open the file once is also an option, but it doesn't sound easy because of the way it invokes external tools).

2) Builder could call G-C-A again after the file is saved, and this will probably work around this problem quite easily.
Comment 7 Christian Hergert 2017-10-20 21:23:54 UTC
I think re-running diagnostics after saving is perfectly reasonable.
Comment 8 GNOME Infrastructure Team 2018-01-11 10:40:59 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-builder/issues/286.