mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-25 20:41:18 -05:00
Add option to disable threads.
This commit is contained in:
parent
b000f87c51
commit
653d9f7297
@ -23,7 +23,14 @@
|
||||
|
||||
# Inject arguments to pretend it's called from the CLI
|
||||
import sys
|
||||
sys.argv = ['supybot', '--allow-root', '--single-loop', '--disable-multiprocessing', 'limnoria.conf']
|
||||
sys.argv = [
|
||||
'supybot',
|
||||
'--allow-root',
|
||||
'--single-loop',
|
||||
'--disable-multiprocessing',
|
||||
'--disable-threading',
|
||||
'limnoria.conf'
|
||||
]
|
||||
|
||||
# Initialize the bot
|
||||
import supybot._main
|
||||
|
@ -3,7 +3,7 @@ supybot.networks.testnet.servers: [fdfe:4421:f18d:fe24:d51c:3fb4:b255:4f09]:8097
|
||||
supybot.networks.testnet.channels: #limnoria-bots
|
||||
supybot.reply.whenAddressedBy.nick: True
|
||||
supybot.drivers.module: PyodideWebsocket
|
||||
supybot.log.stdout.level: DEBUG
|
||||
supybot.log.stdout.level: INFO
|
||||
supybot.plugins: Debug Seen Format Status Unix Math Config Admin Anonymous Plugin MessageParser Network BadWords Chanreg AutoMode Aka Channel Sigyn Utilities Services Factoids Owner User ChannelStats PluginDownloader RSS Web Misc
|
||||
|
||||
supybot.plugins.Admin: True
|
||||
|
@ -29,6 +29,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
self.wfile.write(fd.read())
|
||||
elif self.path == '/limnoria.conf':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'text/plain')
|
||||
with open(CONF_PATH, 'rb') as fd:
|
||||
self.wfile.write(fd.read())
|
||||
elif self.path == '/favicon.ico':
|
||||
|
@ -163,6 +163,7 @@ if __name__ == '__main__':
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
world.disableMultiprocessing = options.disableMultiprocessing
|
||||
world.disableThreading = False
|
||||
|
||||
# This must go before checking for args, of course.
|
||||
if options.excludePlugins:
|
||||
|
@ -171,6 +171,10 @@ def main():
|
||||
dest='disableMultiprocessing',
|
||||
help='Disables multiprocessing stuff. May lead to '
|
||||
'vulnerabilities.')
|
||||
parser.add_option('', '--disable-threading', action='store_true',
|
||||
dest='disableThreading',
|
||||
help='Disables multiprocessing stuff. May lead to '
|
||||
'inefficiencies and denial of service.')
|
||||
parser.add_option('', '--single-loop', action='store_true',
|
||||
dest='singleLoop',
|
||||
help='Do not use this unless you understand what it is.')
|
||||
@ -325,6 +329,7 @@ def main():
|
||||
|
||||
conf.allowDefaultOwner = options.allowDefaultOwner
|
||||
world.disableMultiprocessing = options.disableMultiprocessing
|
||||
world.disableThreading = options.disableThreading
|
||||
|
||||
if not os.path.exists(conf.supybot.directories.log()):
|
||||
os.mkdir(conf.supybot.directories.log())
|
||||
|
@ -765,6 +765,10 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
if hasattr(cb, 'invalidCommand'):
|
||||
cbs.append(cb)
|
||||
threaded = threaded or cb.threaded
|
||||
|
||||
if world.disableThreading:
|
||||
threaded = False
|
||||
|
||||
def callInvalidCommands():
|
||||
self.repliedTo = False
|
||||
for cb in cbs:
|
||||
|
@ -63,6 +63,12 @@ class SupyThread(threading.Thread, object):
|
||||
super(SupyThread, self).__init__(*args, **kwargs)
|
||||
log.debug('Spawning thread %q.', self.getName())
|
||||
|
||||
def start(self):
|
||||
if disableThreading:
|
||||
self.run()
|
||||
else:
|
||||
super().start()
|
||||
|
||||
processesSpawned = 1 # Starts at one for the initial process.
|
||||
class SupyProcess(multiprocessing.Process):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user