From: Cameron Dale <camrdale@gmail.com>
Date: Sun, 9 Dec 2007 03:16:02 +0000 (-0800)
Subject: Removed all unused threading.
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6075497ad81cd8ac5515cc71eaf83964a079a955;p=quix0rs-apt-p2p.git

Removed all unused threading.
---

diff --git a/actions.py b/actions.py
index e25c82b..db2a777 100644
--- a/actions.py
+++ b/actions.py
@@ -87,7 +87,7 @@ class FindNode(ActionBase):
         if self.outstanding == 0:
             ## all done!!
             self.finished=1
-            reactor.callFromThread(self.callback, l[:K])
+            reactor.callLater(0, self.callback, l[:K])
     
     def makeMsgFailed(self, node):
         def defaultGotNodes(err, self=self, node=node):
@@ -150,7 +150,7 @@ class GetValue(FindNode):
             z = len(dict['values'])
             v = filter(None, map(x, dict['values']))
             if(len(v)):
-                reactor.callFromThread(self.callback, v)
+                reactor.callLater(0, self.callback, v)
         self.schedule()
         
     ## get value
@@ -179,7 +179,7 @@ class GetValue(FindNode):
         if self.outstanding == 0:
             ## all done, didn't find it!!
             self.finished=1
-            reactor.callFromThread(self.callback,[])
+            reactor.callLater(0, self.callback,[])
 
     ## get value
     def goWithNodes(self, nodes, found=None):
diff --git a/khashmir.py b/khashmir.py
index 46946eb..10bac3b 100644
--- a/khashmir.py
+++ b/khashmir.py
@@ -18,10 +18,8 @@ import krpc
 
 from twisted.internet.defer import Deferred
 from twisted.internet import protocol
-from twisted.python import threadable
 from twisted.application import service, internet
 from twisted.web import server
-threadable.init()
 import sys
 
 from random import randrange
@@ -164,7 +162,7 @@ class KhashmirBase(protocol.Factory):
         else:
             # create our search state
             state = FindNode(self, id, d.callback)
-            reactor.callFromThread(state.goWithNodes, nodes)
+            reactor.callLater(0, state.goWithNodes, nodes)
     
     def insertNode(self, n, contacted=1):
         """
@@ -300,7 +298,7 @@ class KhashmirRead(KhashmirBase):
         
         # create our search state
         state = GetValue(self, key, callback)
-        reactor.callFromThread(state.goWithNodes, nodes, l)
+        reactor.callLater(0, state.goWithNodes, nodes, l)
 
     def krpc_find_value(self, key, id, _krpc_sender):
         sender = {'id' : id}
@@ -335,7 +333,7 @@ class KhashmirWrite(KhashmirRead):
                     pass
                 response=_storedValueHandler
             action = StoreValue(self.table, key, value, response)
-            reactor.callFromThread(action.goWithNodes, nodes)
+            reactor.callLater(action.goWithNodes, nodes)
             
         # this call is asynch
         self.findNode(key, _storeValueForKey)