mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-03 17:01:05 -05:00
Cleaner thread.
This commit is contained in:
parent
cd9ad40591
commit
107d237cc9
@ -161,6 +161,15 @@ def channel(f):
|
|||||||
ff(irc, msg, args, *L)
|
ff(irc, msg, args, *L)
|
||||||
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
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()
|
_snarfed = structures.smallqueue()
|
||||||
def urlSnarfer(f):
|
def urlSnarfer(f):
|
||||||
"""Protects the snarfer from loops and whatnot."""
|
"""Protects the snarfer from loops and whatnot."""
|
||||||
@ -188,14 +197,11 @@ def urlSnarfer(f):
|
|||||||
f(self, irc, msg, match, *L)
|
f(self, irc, msg, match, *L)
|
||||||
else:
|
else:
|
||||||
L = list(L)
|
L = list(L)
|
||||||
world.threadsSpawned += 1
|
t = UrlSnarfThread(target=f,args=[self,irc,msg,match]+L,url=url)
|
||||||
t = threading.Thread(target=f, args=[self,irc,msg,match]+L)
|
|
||||||
t.setDaemon(True)
|
|
||||||
t.start()
|
t.start()
|
||||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
class CapabilityCheckingPrivmsg(callbacks.Privmsg):
|
class CapabilityCheckingPrivmsg(callbacks.Privmsg):
|
||||||
"""A small subclass of callbacks.Privmsg that checks self.capability
|
"""A small subclass of callbacks.Privmsg that checks self.capability
|
||||||
before allowing any command to be called.
|
before allowing any command to be called.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user