This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
The hardest conversio is (by far) functemplate. It will also reguire a
great length of adaptation for python3, since the grammar of the
language changes and several functions (such as ast.arguments and
ast.FunctionDef) take additional mandatory parameters that don't exist
in python2.
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.
Goal is smoothing the transition to python 3.
This is the first of several commits that will modernize the beets codebase for
Python 2.6 conventions. (Compatibility with Python 2.5 is hereby abandoned.)
I saw this *extremely* intermittently (and wasn't able to reproduce it at all),
but I think there was a race when invalidating an output queue in the abort()
method of PipelineThread. It was possible for a thread's input queue to be
invalidated (with val=None) while abort_flag was False (and abort_lock was not
held). This would cause coroutines to see a None value when the pipeline was
shutting down. Always poisoning a queue when it's invalidated should solve this
by making the thread break before sending the value to the coroutine.
Previously, if an abort occurred during a queue read, then the queue would
return None. With this extra check, the None is never exposed to the user code
(coroutine).
The pipeline module now support stages that have multiple threads working in
parallel; this can bring ordinary task parallelism to parts of a pipelined
workflow. This change also involves making the pipeline terminate immediately
when an exception is raised in a coroutine.