Esempio n. 1
0
class MlanSearch(object):
    def __init__(self):
        self.tasklet = None

    def search(self, line):
        if self.tasklet is None:
            self.reqchannel = Channel()
            self.queued = {}
            self.tasklet = Tasklet(self._checker)
            self.tasklet()
        ch = Channel()
        if line in self.queued:
            self.queued[line].append(ch)
        else:
            self.queued[line] = [ch]
            self.reqchannel.send(line)
        return ch.recv()

    def _checker(self):
        while True:
            line = self.reqchannel.recv()
            waiters = self.reqchannel[line]
            del self.reqchannel[line]
            for waiter in waiters:
                if waiter.has_receiver():
                    waiter.send(["abc", "def", "ghi"])
Esempio n. 2
0
class MlanSearch(object):
    def __init__(self):
        self.tasklet = None

    def search(self, line):
        if self.tasklet is None:
            self.reqchannel = Channel()
            self.queued = {}
            self.tasklet = Tasklet(self._checker)
            self.tasklet()
        ch = Channel()
        if line in self.queued:
            self.queued[line].append(ch)
        else:
            self.queued[line] = [ch]
            self.reqchannel.send(line)
        return ch.recv()

    def _checker(self):
        while True:
            line = self.reqchannel.recv()
            waiters = self.reqchannel[line]
            del self.reqchannel[line]
            for waiter in waiters:
                if waiter.has_receiver():
                    waiter.send(["abc", "def", "ghi"])
Esempio n. 3
0
 def search(self, line):
     if self.tasklet is None:
         self.reqchannel = Channel()
         self.queued = {}
         self.tasklet = Tasklet(self._checker)
         self.tasklet()
     ch = Channel()
     if line in self.queued:
         self.queued[line].append(ch)
     else:
         self.queued[line] = [ch]
         self.reqchannel.send(line)
     return ch.recv()
Esempio n. 4
0
 def search(self, line):
     if self.tasklet is None:
         self.reqchannel = Channel()
         self.queued = {}
         self.tasklet = Tasklet(self._checker)
         self.tasklet()
     ch = Channel()
     if line in self.queued:
         self.queued[line].append(ch)
     else:
         self.queued[line] = [ch]
         self.reqchannel.send(line)
     return ch.recv()