When a new temporary file is created,
self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir)[1]
a file is opened (and its file descriptor is assigned to the [0]
element of that tuple). That file is actually immediately clobbered---it is not used except to avoid races.
That file descriptor can just be immediately closed:
fd,self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir) os.close(fd)
This works (on Linux) and resolves the leak. It resolves an issue that looks like an unresponsive client (in my case right clicking just showed a blank box, with the colored border expected around windows). It failed with an error message like unable to create file descriptor or unable to open file (I've forgotten the exact wording).
Thanks, applied in r24161.
How about r24162 instead?
Do you think there is any merit in handling, e.g., out of space errors?
fd, self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir) try: log("set_icon_from_data%s using temporary file %s", ("%s pixels" % len(pixels), has_alpha, w, h, rowstride), self.tmp_filename) os.write(fd, png_data) finally: os.close(fd) os.fchmod(fd, 0o644)
(Beware untested code.)
Do you think there is any merit in handling, e.g., out of space errors?
r24165 should handle any errors in the section handling IO.
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2451