Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions btsfeed/bts_feed_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import datetime, threading, time
from pprint import pprint

import random


headers = {'content-type': 'application/json',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
Expand Down Expand Up @@ -181,10 +183,12 @@ def get_rate_from_yahoo():
pos = posnext + 1
rate_cny["CNY"] = 0.0
rate_cny["BTC"] = 0.0
threading.Timer( 600, get_rate_from_yahoo).start()
duration = random.normalvariate( 600, 200 )
threading.Timer( duration, get_rate_from_yahoo).start()
except:
print "Warning: unknown error, try again after 1 seconds"
threading.Timer( 1, get_rate_from_yahoo).start()
duration = random.normalvariate( 1, 0.3 )
threading.Timer( duration, get_rate_from_yahoo).start()

def update_feed(publish_feeds):
global update_time
Expand Down Expand Up @@ -250,6 +254,7 @@ def fetch_price():
publish_feeds.append([asset, price_median_source[asset]*discount])
price_publish[asset] = price_median_source[asset]
update_feed(publish_feeds)
duration = random.normalvariate( sample_timer, sample_timer / 3 )
threading.Timer( sample_timer, fetch_price).start()

price = {}
Expand Down