Skip to content

Commit

Permalink
moved send logic to Transport
Browse files Browse the repository at this point in the history
  • Loading branch information
m0mchil committed Sep 27, 2012
1 parent 842d652 commit bb543e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 1 addition & 4 deletions HttpTransport.py
Expand Up @@ -51,10 +51,7 @@ def loop(self):
self.queue_work(work, miner)
miner = self.servers.updatable_miner()

while not self.result_queue.empty():
result = self.result_queue.get(False)
with self.servers.lock:
self.servers.send(result, self.send_internal)
self.process_result_queue()
sleep(1)
except Exception:
say_exception("Unexpected error:")
Expand Down
8 changes: 1 addition & 7 deletions StratumTransport.py
Expand Up @@ -101,13 +101,7 @@ def loop(self):
continue

with self.send_lock:
while not self.result_queue.empty():
result = self.result_queue.get(False)
#if not self.send(result):
if not self.servers.send(result, self.send_internal):
self.result_queue.put(result)
self.stop()
break
self.process_result_queue()
sleep(1)

def asyncore_thread(self):
Expand Down
11 changes: 10 additions & 1 deletion Transport.py
Expand Up @@ -18,4 +18,13 @@ def loop(self):
def check_failback(self):
if self.servers.server_index != 0 and time() - self.last_failback > self.options.failback:
self.stop()
return True
return True

def process_result_queue(self):
while not self.result_queue.empty():
result = self.result_queue.get(False)
with self.servers.lock:
if not self.servers.send(result, self.send_internal):
self.result_queue.put(result)
self.stop()
break

0 comments on commit bb543e0

Please sign in to comment.