Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GobjectQueue(Queue.Queue):
- def __init__(self,*args):
- self.callback = []
- self.sock = socket.socket()
- while 1:
- try:
- self.port = random.randint(50000,65534)
- self.sock.bind(("127.0.0.1",self.port))
- self.sock.listen(1)
- break;
- except:
- continue
- gobject.io_add_watch(self.sock, gobject.IO_IN, self._on_data)
- Queue.Queue.__init__(self, *args)
- def put(self, data):
- Queue.Queue.put(self,data)
- s = socket.socket()
- s.connect(("127.0.0.1",self.port))
- def get(self,*args,**kw):
- self.sock.accept()
- return Queue.Queue.get(self,timeout=0.1)
- def _on_data(self,*args):
- for i in self.callback:
- i(self)
- return True
Add Comment
Please, Sign In to add comment