[28588] in Source-Commits
Re: build-system commit: Output error message when dabuild fails
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Fri Mar 11 22:09:57 2016
From: Jonathan D Reed <jdreed@mit.edu>
To: Alexander Chernyakhovsky <achernya@mit.edu>
CC: Victor Vasiliev <vasilvv@mit.edu>, source-commits <source-commits@mit.edu>
Date: Sat, 12 Mar 2016 03:09:51 +0000
Message-ID: <320C34A5-3507-48E7-B944-31D2A702832D@mit.edu>
In-Reply-To: <CAB18ysoqHhQLBh5P0Hw96Hu2djtgsu1xjDMbwZTu5-o4wxV13g@mail.gmail.com>
Content-Language: en-US
Content-Type: text/plain; charset="Windows-1252"
Content-ID: <B6BB29C20F0AEE4099BB0C712F7FC8FD@exchange.mit.edu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Per zephyr, we have determined that a bare raise inside an except: clause is correct, thread-safe, and the preferred way of preserving the stack trace. However, a bare raise outside, but immediately following a try block, while syntactically incorrect, does work for some reason and can apparently get you something unholy in a multi-threaded environment, and that accidentally moving a bare raise outside a try block might lull you into a false sense of security, whereas a "raise e" would either raise the exception or throw NameError. TIL.
-Jon
On Mar 11, 2016, at 9:30 PM, Alex Chernyakhovsky <achernya@mit.edu> wrote:
> You never want a bare raise. Python's implicit raise is not thread safe, IIRC.
>
> -Alex
>
> On Fri, Mar 11, 2016 at 9:24 PM, Jonathan D Reed <jdreed@mit.edu> wrote:
>> Doesn’t that want to be a bare “raise” instead of “raise err” so that the stack trace is preserved? Not that that last frame will be particularly useful, but I think it’s good form.
>>
>> -Jon
>>
>> On Mar 11, 2016, at 5:37 PM, Victor Vasiliev <vasilvv@MIT.EDU> wrote:
>>
>>> https://github.com/mit-athena/build-system/commit/e54c602fd0ee1d4c092c876abcb8d81b31988993
>>> commit e54c602fd0ee1d4c092c876abcb8d81b31988993
>>> Author: Victor Vasiliev <vasilvv@mit.edu>
>>> Date: Fri Mar 11 17:26:38 2016 -0500
>>>
>>> Output error message when dabuild fails
>>>
>>> dabuild | 6 +++++-
>>> 1 files changed, 5 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/dabuild b/dabuild
>>> index c72bfb6..35a46d9 100755
>>> --- a/dabuild
>>> +++ b/dabuild
>>> @@ -312,7 +312,11 @@ if __name__ == '__main__':
>>> print >>sys.stderr, "The lock is in place; unable to proceed"
>>> sys.exit(1)
>>> try:
>>> - main()
>>> + try:
>>> + main()
>>> + except subprocess.CalledProcessError as err:
>>> + print err.output
>>> + raise err
>>> finally:
>>> dabuildsys.release_lock()
>>>
>>