You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gmod.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # import gmod2
  2. print("===========================================================================================================================================")
  3. OKBLUE = '\033[94m'
  4. ENDC = '\033[0m'
  5. # print("GLOBA_REINIT" ,OKBLUE,"###################################################################",ENDC)
  6. glob = {}
  7. dbg_glob = {}
  8. glob["WSGI_RLD_HANDLERS"] = []
  9. def before_mod_rld(mod,*a,**kw):
  10. h = getattr(mod,"MOD_RLD_HANDLERS",None)
  11. print("before_mod_rld:",mod,h)
  12. cnt=0
  13. while h:
  14. fn=h.pop()
  15. print(cnt)
  16. cnt+=1
  17. fn()
  18. def reg_mod_rld_handler(mod,fn,*a,**kw):
  19. h = getattr(mod,"MOD_RLD_HANDLERS",None)
  20. if h is None:
  21. mod.MOD_RLD_HANDLERS = []
  22. h= mod.MOD_RLD_HANDLERS
  23. h.append(fn)
  24. print("reg_mod_rld_handler:",h,mod)
  25. def unreg_rld_handler(fn,*a,**kw):
  26. if fn in glob["WSGI_RLD_HANDLERS"]:
  27. print("unreg_rld_handler",fn)
  28. glob["WSGI_RLD_HANDLERS"].remove(fn)
  29. else:
  30. print("unreg_rld_handler~~~",fn)
  31. # print()
  32. def reg_rld_handler(fn,*a,**kw):
  33. glob["WSGI_RLD_HANDLERS"].append(fn)
  34. def before_wsgi_rld(s=""):
  35. print("before_wsgi_rld:",s)
  36. cnt=0
  37. while glob["WSGI_RLD_HANDLERS"]:
  38. fn=glob["WSGI_RLD_HANDLERS"].pop()
  39. print(cnt)
  40. cnt+=1
  41. fn()
  42. # or should we do import
  43. # is this better or the worst way we shall find out
  44. def W():
  45. return glob