Made the reload mechanism fully asynchronous. Work on improving cache operations.

This commit is contained in:
Griatch 2011-03-20 13:24:07 +00:00
parent 85e61bbf2d
commit e965830735
6 changed files with 113 additions and 59 deletions

View file

@ -19,7 +19,7 @@ class ObjManipCommand(MuxCommand):
some optional data, such as a typeclass or a location. A comma ','
separates different objects. Like this:
name1;alias;alias;alias:option, name2 ;alias;alias ...
name1;alias;alias;alias:option, name2;alias;alias ...
Spaces between all components are stripped.
@ -1360,7 +1360,7 @@ class CmdExamine(ObjManipCommand):
text = "%s[...]" % text[:line_width - headlen - 5]
return text
def format_attributes(self, obj, attrname=None):
def format_attributes(self, obj, attrname=None, crop=True):
"""
Helper function that returns info about attributes and/or
non-persistent data stored on object
@ -1382,12 +1382,14 @@ class CmdExamine(ObjManipCommand):
#self.caller.msg(db_attr)
string += "\n{wPersistent attributes{n:"
for attr, value in db_attr:
value = self.crop_line(value, attr)
if crop:
value = self.crop_line(value, attr)
string += "\n %s = %s" % (attr, value)
if ndb_attr and ndb_attr[0]:
string += "\n{wNon-persistent attributes{n:"
for attr, value in ndb_attr:
value = self.crop_line(value, attr)
if crop:
value = self.crop_line(value, attr)
string += "\n %s = %s" % (attr, value)
return string
@ -1472,14 +1474,16 @@ class CmdExamine(ObjManipCommand):
obj = caller.search(obj_name)
if not obj:
continue
if not obj.access(caller, 'examine'):
#If we don't have special info access, just look at the object instead.
caller.execute_cmd('look %s' % obj_name)
continue
if obj_attrs:
for attrname in obj_attrs:
# we are only interested in specific attributes
string += self.format_attributes(obj, attrname)
string += self.format_attributes(obj, attrname, crop=False)
else:
string += self.format_output(obj)
string = string.strip()

View file

@ -438,8 +438,8 @@ class CmdSay(MuxCommand):
emit_string = '{c%s{n says, "%s{n"' % (caller.name,
speech)
caller.location.msg_contents(emit_string,
exclude=caller)
exclude=caller)
## def cmd_fsay(command):
## """
## @fsay - make an object say something

View file

@ -38,29 +38,30 @@ class CmdReload(MuxCommand):
Reload the system.
"""
caller = self.caller
reloads.reload_modules()
reloads.start_reload_loop()
max_attempts = 4
for attempt in range(max_attempts):
# if reload modules take a long time,
# we might end up in a situation where
# the subsequent commands fail since they
# can't find the reloads module (due to it
# not yet fully loaded). So we retry a few
# times before giving up.
try:
reloads.reload_scripts()
reloads.reload_commands()
break
except AttributeError:
if attempt < max_attempts-1:
caller.msg(" Waiting for modules(s) to finish (%s) ..." % attempt)
else:
string = "{r ... The module(s) took too long to reload, "
string += "\n so the remaining reloads where skipped."
string += "\n Re-run @reload again when modules have fully "
string += "\n re-initialized.{n"
caller.msg(string)
#reloads.reload_modules()
# max_attempts = 4
# for attempt in range(max_attempts):
# # if reload modules take a long time,
# # we might end up in a situation where
# # the subsequent commands fail since they
# # can't find the reloads module (due to it
# # not yet fully loaded). So we retry a few
# # times before giving up.
# try:
# reloads.reload_scripts()
# reloads.reload_commands()
# break
# except AttributeError:
# if attempt < max_attempts-1:
# caller.msg(" Waiting for modules(s) to finish (%s) ..." % attempt)
# else:
# string = "{r ... The module(s) took too long to reload, "
# string += "\n so the remaining reloads where skipped."
# string += "\n Re-run @reload again when modules have fully "
# string += "\n re-initialized.{n"
# caller.msg(string)
class CmdPy(MuxCommand):
"""