Server Help

ASSS Questions - python reload config after config changed

Plareplane - Tue Jul 11, 2006 10:38 pm
Post subject: python reload config after config changed
The py version of OpenConfigFile only takes two arguments. Is there a way for a python module to be notified when a config file changes?
Grelminar - Wed Jul 12, 2006 2:03 am
Post subject:
Hmm. That's a little tricky, but should be possible. Please file a feature request so that I don't forget about it (though I probably wont get to it any time soon).

Although, I should ask why you are using OpenConfigFile in the first place. In general, you should put your settings in either global.conf (for global stuff) or arena.conf (for per-arena stuff), and then you can use the cb_globalconfchanged or cb_arenaaction callbacks.
Plareplane - Wed Jul 12, 2006 2:57 am
Post subject:
Probably because I didn't realize that the arenaaction callback gets called for an arena config change. (So, that actually solves my actual problem.)

But, what if I want to have something per-module? On third thought, if it's per-module then you could might as well include/stuff it in the global conf?
Plareplane - Wed Jul 12, 2006 3:27 am
Post subject:
Now that I'm using CB_ARENAACTION, I'm not sure why this deadlocks when I change the settings:
Code: Show/Hide

from asss import *
aman = get_interface(I_ARENAMAN)
cfg = get_interface(I_CONFIG)
chat = get_interface(I_CHAT)

def mm_load(arena):
   ed = cfg.GetInt(arena.cfg, "Kill", "EnterDelay", 0)

def aaction(arena, action):
   chat.SendArenaMessage(arena, "breakpoint 1")
   if action == AA_CONFIGCHANGED:
      chat.SendArenaMessage(arena, "breakpoint 2")
      ed = cfg.GetInt(arena.cfg, "Kill", "EnterDelay", 0)
      chat.SendArenaMessage(arena, "breakpoint 3")
cb1 = reg_callback(CB_ARENAACTION, aaction)

console output is:
Code: Show/Hide

I <pymod> loading python module 'demo2'
I <cmdman> {0} [Plareplane] command (arena): insmod <py> demo2
I <filetrans> {0} [Plareplane] sending 'tmp/quickfix-odGf2g' (as 'server.set')
I <cmdman> {0} [Plareplane] command (arena): quickfix enterdelay
I <filetrans> completed send of 'server.set'
I <quickfix> {0} [Plareplane] setting Kill:EnterDelay = 1000
I <config> writing dirty settings: arenas/(default)/arena.conf
I <clientset> {0} sending modified settings
E <deadlock> deadlock detected, aborting
./run-asss: line 101: 31599 Aborted                 $ASSS $CHROOT
*** asss exited: due to signal 6, restarting

code gets past breakpoint 2, but never reaches breakpoint 3
Dr Brain - Wed Jul 12, 2006 7:28 am
Post subject:
Isn't that obvious? You're in an endless loop. You can't change the settings when you're in a settings change callback.
Plareplane - Wed Jul 12, 2006 10:23 am
Post subject:
No, it's not obvious to me. Are you saying that changing ed affects an arena setting somehow? Because I don't see a SetInt anywhere.
Smong - Wed Jul 12, 2006 11:12 am
Post subject:
Dr brain just a made a mistake reading it.

BTW there is no mm_load function. And your variable 'ed' isn't declared as global, and even if it was it might be immutable because it would be in a higher scope.
Want you want to do is use mm_attach and store 'ed' in the arena object like this:
Code: Show/Hide
def mm_attach(a):
    a.cfg_enterdelay = cfg.GetInt(a.cfg, "Kill", "EnterDelay", 200)

Secondly if you want a "respawn callback" there is one in as.py in the UT Project thread. Respawning is complicated because you must also take into account ship/freq changes and entering the arena.
Plareplane - Wed Jul 12, 2006 11:29 am
Post subject:
Yeah, it was just a stupid snippet made up to demonstrate my problem. Originally, the crash was happening in a somewhat slightly bigger module, and I thought I'd strip out the irrelevant bits to see if it still crashes. Do you know of any python modules that DO reload some config setting after the config changes and DON'T crash?
Grelminar - Thu Jul 13, 2006 4:44 am
Post subject:
Oh, crap, it looks like this is a bug introduced in 1.4.3. One of the mutexes in the config module was made nonrecursive, but it turns out that due to how the python stuff is implemented, it actually needs to be recursive. Or something else needs to change somewhere. I'll try to figure out the best way to fix it.

Update: I think this will fix it: http://asss.yi.org/viewmtn/revision.psp?id=e5881bff96a63733a35eaf20f62b1e94464fc990
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group