harvimt/quamash — pull request #11 by horazont (2014-12-13 15:06:27+00:00)
Title: Implement utility function inline_async

``inline_async`` allows the user to execute a coroutine using the currently active QEventLoop in a nested fashion, like ``QDialog::exec`` does. This allows to run a coroutine inside a slot / callback attached to a signal.

Example:
```python
import asyncio
import sys

import PyQt4.Qt as Qt

import quamash

@asyncio.coroutine
def long_task():
print("working hard ... ")
yield from asyncio.sleep(1)
print("done!")

def run_long_task():
quamash.inline_async(long_task())

app = Qt.QApplication(sys.argv)
win = Qt.QMainWindow()
btn = Qt.QPushButton(win)
btn.setText("Run long_task")
btn.clicked.connect(run_long_task)
win.show()

asyncio.set_event_loop(quamash.QEventLoop(app=app))
asyncio.get_event_loop().run_forever()
```