Convert PerforceClient.run_worker to be a context manager.

Review Request #8943 - Created May 16, 2017 and submitted

Christian Hammond
Review Board
release-2.5.x
0a827f2...
reviewboard

run_worker(), which establishes a Perforce session, used to take a
function as a parameter to run, which meant that callers had to define
an extra function or provide a lambda. Now it works as a context
manager, reducing the work needed by the callers.

As part of this, run_worker() now handles converting exceptions by
itself, without needing the old _convert_p4exception_to_scmexception()
utility method, simplifying code a bit more.

This also fleshes out the documentation for the affected functions.

Unit tests passed.

Tested Perforce functionality manually. Everything works as it did
before.

David Trowbridge
  1. Ship It!
  2. 
      
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (0ad70b0)
Loading...