Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
python reload config after config changed

 
Post new topic   Reply to topic Printable version
 View previous topic  Difference between as3 windows/linux m... Post :: Post Deleting old cfg values  View next topic  
Author Message
Plareplane
Newbie


Joined: Jul 09 2006
Posts: 14
Offline

PostPosted: Tue Jul 11, 2006 10:38 pm    Post subject: python reload config after config changed Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Wed Jul 12, 2006 2:03 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website
Plareplane
Newbie


Joined: Jul 09 2006
Posts: 14
Offline

PostPosted: Wed Jul 12, 2006 2:57 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Plareplane
Newbie


Joined: Jul 09 2006
Posts: 14
Offline

PostPosted: Wed Jul 12, 2006 3:27 am    Post subject: Reply to topic Reply with quote

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
Back to top
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Jul 12, 2006 7:28 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Plareplane
Newbie


Joined: Jul 09 2006
Posts: 14
Offline

PostPosted: Wed Jul 12, 2006 10:23 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Wed Jul 12, 2006 11:12 am    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Plareplane
Newbie


Joined: Jul 09 2006
Posts: 14
Offline

PostPosted: Wed Jul 12, 2006 11:29 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Thu Jul 13, 2006 4:44 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 36 page(s) served in previous 5 minutes.

phpBB Created this page in 0.502733 seconds : 33 queries executed (83.7%): GZIP compression disabled