Author |
Message |
Plareplane Newbie
Joined: Jul 09 2006 Posts: 14 Offline
|
Posted: 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? |
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: 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. |
|
Back to top |
|
 |
Plareplane Newbie
Joined: Jul 09 2006 Posts: 14 Offline
|
Posted: 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?
Last edited by Plareplane on Wed Jul 12, 2006 3:29 am, edited 1 time in total |
|
Back to top |
|
 |
Plareplane Newbie
Joined: Jul 09 2006 Posts: 14 Offline
|
Posted: 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:
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:
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 |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Plareplane Newbie
Joined: Jul 09 2006 Posts: 14 Offline
|
Posted: 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. |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
 |
Plareplane Newbie
Joined: Jul 09 2006 Posts: 14 Offline
|
Posted: 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? |
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: 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 |
|
Back to top |
|
 |
|