Message Boards Message Boards


Avoid auto-update from GitHub and URLSaveAsynchronous hanging?

Posted 5 years ago
3 Replies
2 Total Likes

I was trying to make an auto-update script for my packages. It would find, download and install the latest version. The problem is that sometimes URLSaveAsynchronous hangs. This happens more often on Windows than on other platforms, but it doesn't always happen. The frustrating thing is that since it happens randomly, I can't easy test for the reason.

Does anyone have a clue about what may be wrong?

The piece of code that hangs:

progress = 0.;
  If[#2 === "progress", progress = Quiet[#3[[1]]/#3[[2]]] ] &,
  "Progress" -> True

At this moment I am really not sure whether the hang is related to the progress indicator. I observed the problem on all OSs, but it happened most often on Windows with M11.0.

The same thing in context is below. Note that the code is intended to be compatible with M10.0. I know that there are newer functions for some of these things.

updateMaTeX[] :=
  Module[{json, download, target, progress = 0.},
      json = Import["", "JSON"];
      download = Lookup[First@Lookup[json, "assets"], "browser_download_url"];
      target = FileNameJoin[{CreateDirectory[], "MaTeX.paclet"}];
        download, target,
        If[#2 === "progress", progress = Quiet[#3[[1]]/#3[[2]]] ] &,
        "Progress" -> True
    If[FileExistsQ[target], PacletInstall[target], $Failed]
3 Replies

Oh, the problem is specific to WaitAsynchronousTask / URLSaveAsynchronous. Of course, there are lots of other ways if you don't use these.

Thanks for confirming this! It was driving me crazy.

Do you mean that there isn't a workaround even if I am willing to give up the progress bar? There are other functions, such as URLSave, URLDownload (v11 only), Export["file", Import["http://...", "String"], "String"], etc. Should I try these instead or do they all use the same back end to download things?

I think this is a known issue and is expected to be addressed in the next release.

The only workaround I am aware of is to set the "Timeout" option of WaitAsynchronousTask.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract