]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Removed all unused threading.
authorCameron Dale <camrdale@gmail.com>
Sun, 9 Dec 2007 03:16:02 +0000 (19:16 -0800)
committerCameron Dale <camrdale@gmail.com>
Sun, 9 Dec 2007 03:16:02 +0000 (19:16 -0800)
actions.py
khashmir.py

index e25c82b75ebe5f32d38fd258b7df0fce40de220b..db2a7774e531fc0783690a3c2a6c205d9c39841a 100644 (file)
@@ -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):
index 46946ebafab4863aa2c83fc0424a94efcf809be4..10bac3bac0f5ebc89ffd54c5cfe51aec5ee48106 100644 (file)
@@ -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)