def start_reload_loop(): """ This starts the asynchronous reset loop. While important that it runs asynchronously (to not block the mud while its running), the order at which things are updated does matter. """ def run_loop(): "" cemit_info('-'*50) cemit_info(" Starting asynchronous server reload.") reload_modules() reload_scripts() reload_commands() reset_loop() def at_return(r): "default callback" cemit_info(" Asynchronous server reload finished.\n" + '-'*50) def at_err(e): "error callback" string = " Reload: Asynchronous reset exited with an error:\n {r%s{n" % e.getErrorMessage() cemit_info(string) utils.run_async(run_loop, at_return, at_err)
def func(self): def test(): li = [] for l in range(10000): li.append(l) self.caller.msg(li[-1]) return "This is the return text" #print 1/0 def succ(f): self.caller.msg("This is called after successful completion. Return value: %s" % f) def err(e): self.caller.msg("An error was encountered... %s" % e) #self.caller.msg("printed before call to sync run ...") #test() #self.caller.msg("after after call to sync run...") self.caller.msg("printed before call to async run ...") utils.run_async(test, at_return=succ, at_err=err) self.caller.msg("printed after call to async run ...")
else: procpool = True if procpool: # run in parallel process def callback(r): caller.msg(" {GBatchfile '%s' applied." % python_path) purge_processor(caller) def errback(e): caller.msg(" {RError from processor: '%s'" % e) purge_processor(caller) utils.run_async(_PROCPOOL_BATCHCMD_SOURCE, commands=commands, caller=caller, at_return=callback, at_err=errback) else: # run in-process (might block) for inum in range(len(commands)): # loop through the batch file if not batch_cmd_exec(caller): return step_pointer(caller, 1) # clean out the safety cmdset and clean out all other # temporary attrs. string = " Batchfile '%s' applied." % python_path caller.msg("{G%s" % string) purge_processor(caller)
def at_repeat(self): if self.db.mobs_spawned is False: number_of_mobs = random.randrange(1,4) utils.run_async(self.obj.spawn_mobs(number_of_mobs)) self.db.mobs_spawned = True self.obj.scripts.validate()
def on_use(self,caller): self.location.msg_contents("{rAs you touch the glowing red stone, a portal begins to emerge..{n") utils.run_async(self.create_dungeon, at_return=self.at_return)