Run autoprice in thread
This commit is contained in:
parent
0f3dba2b06
commit
26bbe93dd2
|
@ -1,6 +1,7 @@
|
||||||
# Twisted/Klein imports
|
# Twisted/Klein imports
|
||||||
from twisted.logger import Logger
|
from twisted.logger import Logger
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
from twisted.internet.threads import deferToThread
|
||||||
|
|
||||||
# Other library imports
|
# Other library imports
|
||||||
from json import loads
|
from json import loads
|
||||||
|
@ -48,7 +49,7 @@ class Agora(object):
|
||||||
self.lc_dash = LoopingCall(self.loop_check)
|
self.lc_dash = LoopingCall(self.loop_check)
|
||||||
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
||||||
if settings.Agora.Cheat == "1":
|
if settings.Agora.Cheat == "1":
|
||||||
self.lc_cheat = LoopingCall(self.update_prices)
|
self.lc_cheat = LoopingCall(self._update_prices)
|
||||||
self.lc_cheat.start(int(settings.Agora.CheatSec))
|
self.lc_cheat.start(int(settings.Agora.CheatSec))
|
||||||
|
|
||||||
def wrap_dashboard(self):
|
def wrap_dashboard(self):
|
||||||
|
@ -284,6 +285,12 @@ class Agora(object):
|
||||||
ad.append(rate)
|
ad.append(rate)
|
||||||
return ads
|
return ads
|
||||||
|
|
||||||
|
def _update_prices(self):
|
||||||
|
"""
|
||||||
|
Update prices in another thread.
|
||||||
|
"""
|
||||||
|
deferToThread(self.update_prices)
|
||||||
|
|
||||||
def update_prices(self):
|
def update_prices(self):
|
||||||
our_ads = self.enum_ads()
|
our_ads = self.enum_ads()
|
||||||
currencies = [x[2].lower() for x in our_ads]
|
currencies = [x[2].lower() for x in our_ads]
|
||||||
|
|
Loading…
Reference in New Issue