Errors with server-side blocking HTTP requests

This commit is contained in:
James Barnsley
2019-12-27 15:07:28 +13:00
parent 636d37dcc4
commit df1215f9b7
7 changed files with 19 additions and 23 deletions

View File

@ -53,12 +53,6 @@ copydir('src/assets', 'mopidy_iris/static/assets', function(error){
fs.writeFileSync(html_file, html_file_content, 'utf8');
console.log('Setting version in HTML');
console.log('Setting version in Python');
var init_file = "mopidy_iris/core.py";
var init_file_content = fs.readFileSync(init_file, "utf8");
init_file_content = init_file_content.replace(/(?:__version__\ \=\ \')(?:.*)'/, "__version__ = '"+version+"'");
fs.writeFileSync(init_file, init_file_content, 'utf8');
console.log('Setting version in NPM');
var package_file = "package.json";
var package_file_content = fs.readFileSync(package_file, "utf8");

View File

@ -15,7 +15,6 @@ from tornado.escape import json_encode, json_decode
from .system import IrisSystemThread
__version__ = '3.43.0'
if sys.platform == 'win32':
import ctypes
@ -23,7 +22,7 @@ if sys.platform == 'win32':
logger = logging.getLogger(__name__)
class IrisCore(pykka.ThreadingActor):
version = __version__
version = ""
spotify_token = False
queue_metadata = {}
connections = {}
@ -37,29 +36,26 @@ class IrisCore(pykka.ThreadingActor):
"results": []
}
def setup(self, config, core):
self.config = config
self.core = core
##
# Mopidy server is starting
##
def start(self):
self.version = self.load_version()
logger.info('Starting Iris '+self.version)
# Load our commands from file
self.commands = self.load_from_file('commands')
##
# Mopidy is shutting down
##
def stop(self):
logger.info('Stopping Iris')
##
# Save dict object to disk
#
@ -81,7 +77,6 @@ class IrisCore(pykka.ThreadingActor):
except Exception:
return False
##
# Load a dict from disk
#
@ -97,6 +92,18 @@ class IrisCore(pykka.ThreadingActor):
except Exception:
return {}
##
# Load version number from file
#
# @return String
##
def load_version(self):
filepath = os.path.join(os.path.dirname(__file__), '..', 'IRIS_VERSION')
try:
with open(filepath, 'r') as f:
return f.read()
except Exception:
return "Unknown"
##
# Generate a random string
@ -107,7 +114,6 @@ class IrisCore(pykka.ThreadingActor):
def generateGuid(self):
return ''.join(random.choices(string.ascii_uppercase + string.digits, k=12))
##
# Digest a protocol header into it's id/name parts
#
@ -144,9 +150,6 @@ class IrisCore(pykka.ThreadingActor):
"generated": generated
}
def send_message(self, *args, **kwargs):
callback = kwargs.get('callback', None)
data = kwargs.get('data', None)
@ -210,7 +213,6 @@ class IrisCore(pykka.ThreadingActor):
else:
return error
def broadcast(self, *args, **kwargs):
callback = kwargs.get('callback', None)
data = kwargs.get('data', None)
@ -1006,7 +1008,7 @@ class IrisCore(pykka.ThreadingActor):
else:
return response
except (urllib.HTTPError, urllib.URLError) as e:
except (urllib.error.HTTPError, urllib.error.URLError) as e:
error = json.loads(e.read())
error = {'message': 'Could not refresh token: '+error['error_description']}

View File

@ -71208,7 +71208,7 @@ var MopidyMiddleware = function () {
var first_uri = action.uris[first_uri_index];
// add our first track
request(socket, store, 'tracklist.add', { uri: first_uri, at_position: 0 }).then(function (response) {
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 }).then(function (response) {
// play it (only if we got a successful lookup)
if (response.length > 0) {
store.dispatch(mopidyActions.changeTrack(response[0].tlid));

File diff suppressed because one or more lines are too long

View File

@ -100,7 +100,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1577409783";
var build = "1577411296";
var version = "3.43.0";
// Construct the script tag

View File

@ -876,7 +876,7 @@ const MopidyMiddleware = (function () {
var first_uri = action.uris[first_uri_index];
// add our first track
request(socket, store, 'tracklist.add', { uri: first_uri, at_position: 0 })
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 })
.then(
(response) => {
// play it (only if we got a successful lookup)