Raise lock timeout as actual exception #6777

Merged
merged 2 commits into from Jul 25, 2016

Conversation

Projects
None yet
3 participants
Owner

mdboom commented Jul 17, 2016

Fix #3655.

I haven't been able to directly reproduce #3655, so this is all based on theory, but given the symptoms and what we know about it, I'm reasonably certain about what is happening.

If a lock directory accidentally remains on disk in the ~/.cache/matplotlib directory from a previous run, it will wait around 90 seconds waiting for the lock to go away, and then timeout. When it times out, it simply tries again (once), and ultimately fails silently to write the file to disk.

The solution here is to:

  1. Make the timeout much shorter -- this only needs to live for the time it takes to write a ~1MB json file to disk
  2. Make the timeout a custom exception so we can handle it specially and let it bubble all the way out to the user (we still want to handle any other exception as a problem with font files and forcing a rebuild)
@mdboom mdboom Raise lock timeout as actual exception
13af980

mdboom added the needs_review label Jul 17, 2016

@QuLogic QuLogic commented on an outdated diff Jul 17, 2016

lib/matplotlib/cbook.py
@@ -2577,10 +2577,11 @@ def _putmask(a, mask, values):
return np.copyto(a, values, where=mask)
_lockstr = """\
-LOCKERROR: matplotlib is trying to acquire the lock {!r}
+LOCKERROR: matplotlib is trying to acquire the lock
+ {!r}
and has failed. This maybe due to any other process holding this
lock. If you are sure no other matplotlib process in running try
@QuLogic

QuLogic Jul 17, 2016 edited

Member

Might as well fix it to say "is running", too.

Owner

tacaswell commented Jul 18, 2016

also closes #6721

Owner

tacaswell commented Jul 18, 2016

The 2.x branch still has the pickle code.

@mdboom mdboom Fix typo
2e0613a
Owner

mdboom commented Jul 19, 2016

@tacaswell: This still seems to backport cleanly and correctly to 2.x, despite the use of pickle rather than json...

mdboom closed this Jul 20, 2016

mdboom reopened this Jul 20, 2016

@mdboom mdboom added needs_review and removed needs_review labels Jul 20, 2016

Owner

mdboom commented Jul 25, 2016

@tacaswell: I think this is ready for a final review.

@tacaswell tacaswell merged commit 38a32d9 into matplotlib:master Jul 25, 2016

2 of 3 checks passed

coverage/coveralls Coverage decreased (-0.007%) to 70.362%
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

tacaswell removed the needs_review label Jul 25, 2016

@tacaswell tacaswell added a commit that referenced this pull request Jul 25, 2016

@tacaswell tacaswell Merge pull request #6777 from mdboom/fix-font-cache-rebuild-timeout
Raise lock timeout as actual exception
e691c28
Member

QuLogic commented Aug 1, 2016

So this still needs a backport?

Owner

tacaswell commented Aug 2, 2016

I backportd this to v2.x as e691c28 (but forgot to note it, sorry).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment