Merge pull request #561 from bmwalters/event-loop
extern.task: replace GLib event loop with asyncio event loop
This commit is contained in:
@@ -10,7 +10,6 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
curl \
|
||||
eject \
|
||||
flac \
|
||||
gir1.2-glib-2.0 \
|
||||
git \
|
||||
libdiscid0 \
|
||||
libiso9660-dev \
|
||||
@@ -20,7 +19,6 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
make \
|
||||
pkgconf \
|
||||
python3-dev \
|
||||
python3-gi \
|
||||
python3-musicbrainzngs \
|
||||
python3-mutagen \
|
||||
python3-pil \
|
||||
|
||||
@@ -130,8 +130,6 @@ Whipper relies on the following packages in order to run correctly and provide a
|
||||
- To avoid bugs it's advised to use `cd-paranoia` versions ≥ **10.2+0.94+2**
|
||||
- The package named `libcdio-utils`, available on certain Debian and Ubuntu versions, is affected by a bug: it doesn't include the `cd-paranoia` binary (needed by whipper). Only Debian bullseye (testing) / sid (unstable) and Ubuntu focal (20.04) and later versions have a separate `cd-paranoia` package where the binary is provided. For more details on this issue check the relevant bug reports: [#888053 (Debian)](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=888053), [#889803 (Debian)](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889803) and [#1750264 (Ubuntu)](https://bugs.launchpad.net/ubuntu/+source/libcdio/+bug/1750264).
|
||||
- [cdrdao](http://cdrdao.sourceforge.net/), for session, TOC, pre-gap, and ISRC extraction
|
||||
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection), to provide GLib-2.0 methods used by `task.py`
|
||||
- [PyGObject](https://pypi.org/project/PyGObject/), required by `task.py`
|
||||
- [musicbrainzngs](https://pypi.org/project/musicbrainzngs/), for metadata lookup
|
||||
- [mutagen](https://pypi.python.org/pypi/mutagen), for tagging support
|
||||
- [setuptools](https://pypi.python.org/pypi/setuptools), for installation, plugins support
|
||||
@@ -149,7 +147,6 @@ Some dependencies aren't available in the PyPI. They can be probably installed u
|
||||
|
||||
- [cd-paranoia](https://github.com/rocky/libcdio-paranoia)
|
||||
- [cdrdao](http://cdrdao.sourceforge.net/)
|
||||
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection)
|
||||
- [libsndfile](http://www.mega-nerd.com/libsndfile/)
|
||||
- [flac](https://xiph.org/flac/)
|
||||
- [sox](http://sox.sourceforge.net/)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
musicbrainzngs
|
||||
mutagen
|
||||
pycdio>0.20
|
||||
PyGObject
|
||||
ruamel.yaml
|
||||
setuptools_scm
|
||||
discid
|
||||
discid
|
||||
|
||||
15
whipper/extern/task/task.py
vendored
15
whipper/extern/task/task.py
vendored
@@ -18,11 +18,10 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with whipper. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from gi.repository import GLib as GLib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -470,7 +469,7 @@ class TaskRunner(LogStub):
|
||||
|
||||
|
||||
class SyncRunner(TaskRunner, ITaskListener):
|
||||
"""Run the task synchronously in a GObject MainLoop."""
|
||||
"""Run the task synchronously in an asyncio event loop."""
|
||||
|
||||
def __init__(self, verbose=True):
|
||||
self._verbose = verbose
|
||||
@@ -484,13 +483,13 @@ class SyncRunner(TaskRunner, ITaskListener):
|
||||
self._verboseRun = verbose
|
||||
self._skip = skip
|
||||
|
||||
self._loop = GLib.MainLoop()
|
||||
self._loop = asyncio.new_event_loop()
|
||||
self._task.addListener(self)
|
||||
# only start the task after going into the mainloop,
|
||||
# otherwise the task might complete before we are in it
|
||||
GLib.timeout_add(0, self._startWrap, self._task)
|
||||
self._loop.call_soon(self._startWrap, self._task)
|
||||
self.debug('run loop')
|
||||
self._loop.run()
|
||||
self._loop.run_forever()
|
||||
|
||||
self.debug('done running task %r', task)
|
||||
if task.exception:
|
||||
@@ -529,7 +528,7 @@ class SyncRunner(TaskRunner, ITaskListener):
|
||||
self.stopped(task)
|
||||
raise
|
||||
|
||||
GLib.timeout_add(int(delta * 1000), c)
|
||||
self._loop.call_later(delta, c)
|
||||
|
||||
# ITaskListener methods
|
||||
def progressed(self, task, value):
|
||||
@@ -564,7 +563,7 @@ class SyncRunner(TaskRunner, ITaskListener):
|
||||
def stopped(self, task):
|
||||
self.debug('stopped task %r', task)
|
||||
self.progressed(task, 1.0)
|
||||
self._loop.quit()
|
||||
self._loop.stop()
|
||||
|
||||
def _report(self):
|
||||
self._output('%s %3d %%' % (
|
||||
|
||||
Reference in New Issue
Block a user