class LongPoller(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.active = False
        self.longpollingurl = None

    def setURL(self,lpurl):
        #lp = urlparse(lpurl)
        #if lp.netloc == '':
        #    p = lp.path
        #    lp = urlparse(url)
        #    lp.path = p
        #else:
        #    if len(lp.netloc.split('@')) != 2:
        #        lp.netloc = '%s:%s@%s'%(user,password,lp.netloc)
        self.longpollingurl = urljoin(url,lpurl)
        self.longpoll = ServiceProxy(self.longpollingurl)

    def run(self):
        self.active = True
        while True:
            try:
                (work,info) = self.longpoll.getwork()
                writer.setwork(work)
                golden.set()
                #print("Long Poll set new work", work)
            except:
                pass
 def setURL(self,lpurl):
     #lp = urlparse(lpurl)
     #if lp.netloc == '':
     #    p = lp.path
     #    lp = urlparse(url)
     #    lp.path = p
     #else:
     #    if len(lp.netloc.split('@')) != 2:
     #        lp.netloc = '%s:%s@%s'%(user,password,lp.netloc)
     self.longpollingurl = urljoin(url,lpurl)
     self.longpoll = ServiceProxy(self.longpollingurl)