Python 3 asyncio selectors fix #344
5 changed files with 37 additions and 10 deletions
|
@ -30,6 +30,10 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
full_status: true,
|
full_status: true,
|
||||||
}).then(([fileInfo]) => {
|
}).then(([fileInfo]) => {
|
||||||
if (!fileInfo || fileInfo.written_bytes === 0) {
|
if (!fileInfo || fileInfo.written_bytes === 0) {
|
||||||
|
// if the outpoint isn't in the state, then it was probably canceled, so stop checking the load status
|
||||||
|
const { downloadingByOutpoint = {} } = state.fileInfo;
|
||||||
|
if (!downloadingByOutpoint[outpoint]) return;
|
||||||
|
|
||||||
// download hasn't started yet
|
// download hasn't started yet
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dispatch(doUpdateLoadStatus(uri, outpoint));
|
dispatch(doUpdateLoadStatus(uri, outpoint));
|
||||||
|
@ -133,7 +137,7 @@ export function doStopDownloadingFile(uri, fileInfo) {
|
||||||
Lbry.file_set_status(params).then(() => {
|
Lbry.file_set_status(params).then(() => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.DOWNLOADING_CANCELED,
|
type: ACTIONS.DOWNLOADING_CANCELED,
|
||||||
data: {}
|
data: { uri, outpoint: fileInfo.outpoint }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Should also delete the file after the user stops downloading
|
// Should also delete the file after the user stops downloading
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
// This depends on the openjdk-8-jdk package (Ubuntu) being installed
|
|
||||||
compileJava {
|
|
||||||
options.fork = true
|
|
||||||
options.forkOptions.executable = /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
|
|
||||||
}
|
|
||||||
|
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -161,7 +161,7 @@ class Python3Recipe(TargetPythonRecipe):
|
||||||
def prebuild_arch(self, arch):
|
def prebuild_arch(self, arch):
|
||||||
super(Python3Recipe, self).prebuild_arch(arch)
|
super(Python3Recipe, self).prebuild_arch(arch)
|
||||||
if self.version == '3.6':
|
if self.version == '3.6':
|
||||||
Python3Recipe.patches = ['patch_python3.6.patch']
|
Python3Recipe.patches = ['patch_python3.6.patch', 'selectors.patch']
|
||||||
build_dir = self.get_build_dir(arch.arch)
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
shprint(sh.ln, '-sf',
|
shprint(sh.ln, '-sf',
|
||||||
realpath(join(build_dir, 'Lib/site-packages/README.txt')),
|
realpath(join(build_dir, 'Lib/site-packages/README.txt')),
|
||||||
|
|
15
recipes/python3crystax/selectors.patch
Normal file
15
recipes/python3crystax/selectors.patch
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
--- a/Lib/selectors.py 2018-06-27 00:39:50.000000000 +0100
|
||||||
|
+++ b/Lib/selectors.py 2018-10-28 17:39:46.027757518 +0100
|
||||||
|
@@ -599,9 +599,9 @@
|
||||||
|
# Choose the best implementation, roughly:
|
||||||
|
# epoll|kqueue|devpoll > poll > select.
|
||||||
|
# select() also can't accept a FD > FD_SETSIZE (usually around 1024)
|
||||||
|
-if 'KqueueSelector' in globals():
|
||||||
|
- DefaultSelector = KqueueSelector
|
||||||
|
-elif 'EpollSelector' in globals():
|
||||||
|
+#if 'KqueueSelector' in globals():
|
||||||
|
+# DefaultSelector = KqueueSelector
|
||||||
|
+if 'EpollSelector' in globals():
|
||||||
|
DefaultSelector = EpollSelector
|
||||||
|
elif 'DevpollSelector' in globals():
|
||||||
|
DefaultSelector = DevpollSelector
|
|
@ -1,10 +1,24 @@
|
||||||
|
import sys
|
||||||
|
from twisted.internet import asyncioreactor
|
||||||
|
if 'twisted.internet.reactor' not in sys.modules:
|
||||||
|
asyncioreactor.install()
|
||||||
|
|||||||
|
else:
|
||||||
|
from twisted.internet import reactor
|
||||||
|
if not isinstance(reactor, asyncioreactor.AsyncioSelectorReactor) and getattr(sys, 'frozen', False):
|
||||||
|
# pyinstaller hooks install the default reactor before
|
||||||
|
# any of our code runs, see kivy for similar problem:
|
||||||
|
# https://github.com/kivy/kivy/issues/4182
|
||||||
|
del sys.modules['twisted.internet.reactor']
|
||||||
|
asyncioreactor.install()
|
||||||
|
from twisted.internet import reactor
|
||||||
|
|
||||||
import keyring.backend
|
import keyring.backend
|
||||||
import platform
|
import platform
|
||||||
import ssl
|
import ssl
|
||||||
|
from jnius import autoclass
|
||||||
|
|
||||||
# Fixes / patches / overrides
|
# Fixes / patches / overrides
|
||||||
# platform.platform() in libc_ver: IOError: [Errno 21] Is a directory
|
# platform.platform() in libc_ver: IOError: [Errno 21] Is a directory
|
||||||
from jnius import autoclass
|
|
||||||
lbrynet_utils = autoclass('io.lbry.browser.Utils')
|
lbrynet_utils = autoclass('io.lbry.browser.Utils')
|
||||||
service = autoclass('io.lbry.browser.LbrynetService').serviceInstance
|
service = autoclass('io.lbry.browser.LbrynetService').serviceInstance
|
||||||
platform.platform = lambda: 'Android %s (API %s)' % (lbrynet_utils.getAndroidRelease(), lbrynet_utils.getAndroidSdk())
|
platform.platform = lambda: 'Android %s (API %s)' % (lbrynet_utils.getAndroidRelease(), lbrynet_utils.getAndroidSdk())
|
||||||
|
@ -76,7 +90,7 @@ keyring.set_keyring(LbryAndroidKeyring())
|
||||||
|
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
from lbrynet.core import log_support
|
from lbrynet.core import log_support
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
from lbrynet import analytics
|
from lbrynet import analytics
|
||||||
from lbrynet import conf
|
from lbrynet import conf
|
||||||
|
|
Loading…
Reference in a new issue
This might lead to confusing results if the wrong reactor was installed previously. I think it would better to either 1) just
asyncioreactor.install()
without putting it inside of a conditional or, alternately, 2) add anelse
to the existing condition which checks that the reactor installed previously is in fact anasyncioreactor
.