From 107d237cc94d0fe74d7f643fc5c2f6b8b54cff0d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 18 Aug 2004 18:48:36 +0000 Subject: [PATCH] Cleaner thread. --- src/privmsgs.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/privmsgs.py b/src/privmsgs.py index 72061864c..b40dfb614 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -161,6 +161,15 @@ def channel(f): ff(irc, msg, args, *L) return utils.changeFunctionName(newf, f.func_name, f.__doc__) +class UrlSnarfThread(threading.Thread): + def __init__(self, *args, **kwargs): + assert 'url' in kwargs + kwargs['name'] = 'Thread #%s (for snarfing %s)' % \ + (world.threadsSpawned, kwargs.pop('url')) + world.threadsSpawned += 1 + threading.Thread.__init__(self, *args, **kwargs) + self.setDaemon(True) + _snarfed = structures.smallqueue() def urlSnarfer(f): """Protects the snarfer from loops and whatnot.""" @@ -188,14 +197,11 @@ def urlSnarfer(f): f(self, irc, msg, match, *L) else: L = list(L) - world.threadsSpawned += 1 - t = threading.Thread(target=f, args=[self,irc,msg,match]+L) - t.setDaemon(True) + t = UrlSnarfThread(target=f,args=[self,irc,msg,match]+L,url=url) t.start() newf = utils.changeFunctionName(newf, f.func_name, f.__doc__) return newf - class CapabilityCheckingPrivmsg(callbacks.Privmsg): """A small subclass of callbacks.Privmsg that checks self.capability before allowing any command to be called.