Changeset 2267:f475f0ece862

Show
Ignore:
Timestamp:
08/27/08 05:53:08 (3 months ago)
Author:
dunker@…
Branch:
default
Message:

move asyncore.loop into RestClientAsync?

Location:
gozerbot
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • gozerbot/net/client.py

    r2253 r2267  
    1 # gozerbot/net/server.py 
     1# gozerbot/net/client.py 
    22# 
    33#  
     
    99class Client(RestClientAsync): 
    1010 
    11     def get(self): 
    12         self.sendget() 
    13  
    1411    def auth(self, userhost, perm): 
    1512        kwargs = {} 
  • gozerbot/net/cloud.py

    r2266 r2267  
    1212from gozerbot.datadir import datadir 
    1313from gozerbot.contrib.simplejson import dumps 
    14 import asyncore, time, os 
     14import asyncore, time, os, random 
    1515 
    1616state = PersistState(datadir + os.sep + 'cloud') 
    1717state.define('nodes', []) 
    1818state.define('names', {}) 
     19 
     20CloudMap = {} 
    1921 
    2022class Node(object): 
     
    3941        self.client = Client(self.url + mount, self.name).addcb(cb) 
    4042        self.client.get() 
     43        return self.client 
    4144 
    4245    def dopost(self, mount, cb, *args, **kwargs): 
    4346        self.client = Client(self.url + mount, self.name).addcb(cb) 
    4447        self.client.post(**kwargs) 
     48        return self.client 
    4549 
    4650class Cloud(object): 
     
    8993            self.add(name, url) 
    9094        self.boot(regname, regport, booturl) 
    91              
     95 
    9296    def persist(self, name, url): 
    9397        self.startup.set('start', name, url) 
     
    132136        for url, node in self.nodes.iteritems(): 
    133137            node.doget(mount, *args, **kwargs) 
    134         start_new_thread(asyncore.loop, (), {'use_poll': True }) 
    135138 
    136139    def dopost(self, mount, *args, **kwargs): 
    137140        for url, node in self.nodes.iteritems(): 
    138141            node.dopost(mount, *args, **kwargs) 
    139         start_new_thread(asyncore.loop, (), {'use_poll': True }) 
    140142 
    141143    def getnodes(self): 
     
    157159        client = Client(url + '/gozernet/+join').addcb(cb) 
    158160        client.post(name=regname, port=regport) 
     161        CloudMap[url + str(random.random())] = client 
    159162 
    160163    def joinall(self, regname, regport): 
     
    192195                gnode = self.add(node[0], node[1]) 
    193196                gnode.synced = time.time() 
    194         Client('%s/gozernet/nodes/' % url).addcb(cb).get() 
     197        client = Client('%s/gozernet/nodes/' % url).addcb(cb) 
     198        CloudMap[url + str(random.random())] = client 
     199        client.get() 
    195200 
    196201    def size(self): 
  • gozerbot/rest/client.py

    r2258 r2267  
    1111from httplib import InvalidURL 
    1212from urlparse import urlparse 
    13 import socket, asynchat, urllib, sys, thread, re 
     13import socket, asynchat, urllib, sys, thread, re, asyncore 
    1414 
    1515restlock = thread.allocate_lock() 
     
    234234        self.start() 
    235235        self.push(s) 
     236        asyncore.loop() 
    236237 
    237238    def sendpost(self, postdata):