Reorganizing to make button press more responsive (#1830)
The delay while loading files have caused the Mark-1 Button to respond very slowly. This moves the sleep out of the loading section and is handled by the token refresh instead.pull/1111/head
parent
9f4a3c264d
commit
5ea6e69f59
|
@ -17,6 +17,8 @@ from copy import copy
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
from requests import HTTPError, RequestException
|
from requests import HTTPError, RequestException
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from mycroft.configuration import Configuration
|
from mycroft.configuration import Configuration
|
||||||
from mycroft.configuration.config import DEFAULT_CONFIG, SYSTEM_CONFIG, \
|
from mycroft.configuration.config import DEFAULT_CONFIG, SYSTEM_CONFIG, \
|
||||||
|
@ -88,9 +90,12 @@ class Api(object):
|
||||||
finally:
|
finally:
|
||||||
identity_lock.release()
|
identity_lock.release()
|
||||||
else: # Someone is updating the identity wait for release
|
else: # Someone is updating the identity wait for release
|
||||||
LOG.debug('Refresh is already in progress, waiting until done')
|
with identity_lock:
|
||||||
self.identity = IdentityManager.load()
|
LOG.debug('Refresh is already in progress, waiting until done')
|
||||||
LOG.debug('new credentials loaded')
|
time.sleep(1.2)
|
||||||
|
os.sync()
|
||||||
|
self.identity = IdentityManager.load(lock=False)
|
||||||
|
LOG.debug('new credentials loaded')
|
||||||
|
|
||||||
def send(self, params, no_refresh=False):
|
def send(self, params, no_refresh=False):
|
||||||
""" Send request to mycroft backend.
|
""" Send request to mycroft backend.
|
||||||
|
|
|
@ -42,8 +42,6 @@ class IdentityManager(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _load():
|
def _load():
|
||||||
LOG.debug('Loading identity')
|
LOG.debug('Loading identity')
|
||||||
time.sleep(1.2)
|
|
||||||
os.sync()
|
|
||||||
try:
|
try:
|
||||||
with FileSystemAccess('identity').open('identity2.json', 'r') as f:
|
with FileSystemAccess('identity').open('identity2.json', 'r') as f:
|
||||||
IdentityManager.__identity = DeviceIdentity(**json.load(f))
|
IdentityManager.__identity = DeviceIdentity(**json.load(f))
|
||||||
|
|
Loading…
Reference in New Issue