Handle exceptions in thread workers

I discovered that exceptions occurring in background threads (as scheduled through the QThreadExecutor) weren't caught and passed on as they should. This patch rectifies that, and there's a test to prove it :)
Each QThread gets it's own Qt Event loop so the other thing it could be
used for is running async jobs in a thread. Overkill? Perhaps we must fall
on the wisdom of Barabas from the A-Team: "Overkill is underrated my
friend."

But that would mean like creating an async event loop policy and whatnot,
not sure it's worth it to have:

@asyncio.coroutine
def coroutine_in_job():
    do_stuff_async()

def job():
    loop = async.get_event_loop()  #gets the event loop for the current
thread or creates one, using threading.local to store thread local data
    loop.run_until_complete(coroutine_in_job())

...
result = yield from loop.run_in_executor(None, job)
...



On Wed, Jul 16, 2014 at 11:31 PM, Mark Harviston <infinull@gmail.com> wrote:

> Merged
>
> Fixed all PEP8 errors except line too long (and installed PEP8 py.test
> plugin)
>
> Testing all executors instead of just the default.
> QThreadExecutors are only necessary for thread workers to receive signals,
> but not to send them, in fact they're kind of useless in some ways, it's
> hard to imagine a circumstance where you'd want to use threadworkers and
> receive signals. Workers are sort of data-in data-out kind of deal, you can
> send data in the arguments field and send data out by return, more
> complicated and you can use threading.Thread or QThreads directly.
>
> QThreadExecutor now uses .shutdown instead of .close (I should have read
> the spec at concurrent.futures more carefully, I always use the
> contextmanager interface so I'd never actually called .shutdown manually)
>
> A couple other stuff too.
>
> Overall we have about 80% test coverage at this point which isn't bad. (I
> haven't tried running py.test --cov on a *nix machine yet)
>
>
>
> On Tue, Jul 15, 2014 at 6:03 AM, Arve Knudsen <notifications@github.com>
> wrote:
>
>> In tests/test_qeventloop.py:
>>
>> > @@ -75,6 +83,7 @@ def test_can_execute_subprocess(loop):
>> >  	assert transport.get_returncode() == 0
>> >  	assert protocol.received_stdout == 'Hello async world!'
>> >
>> > +
>>
>> PEP 8 dictates two lines between functions.
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/harvimt/quamash/pull/3/files#r14932220>.
>>
>
>