Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

tasks_loop.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import asyncio
  2. import time
  3. import redis
  4. import os
  5. import copy
  6. import json
  7. import traceback
  8. import inspect
  9. '''
  10. umod
  11. # '''
  12. p=print
  13. async def anop(*a,**kw):pass
  14. def nop(*a,**kw):pass
  15. def connect_redis():
  16. return redis.Redis(host='localhost', port=6379, db=0,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace")
  17. '''
  18. # '''
  19. # GCLMixin
  20. class globCL():
  21. init_cnt = 0
  22. def __init__(self,*a,**kw):
  23. # for now we are not going to do any weird class stuff
  24. cls = self.__class__
  25. cls.init_cnt += 1
  26. self.r = connect_redis()
  27. pass
  28. async def persistent_loop(self,*a,**kw):
  29. pass
  30. def run_persistent_loop(self,*a,**kw):
  31. pass
  32. # p("300 globCL.init_cnt:",globCL.init_cnt)
  33. glob_cl = globCL()
  34. # p("400 globCL.init_cnt:",globCL.init_cnt)
  35. # glob_cl_b = globCL()
  36. # p("501 globCL.init_cnt:",globCL.init_cnt)
  37. # print("..",end="\n",flush=True)
  38. def redis_info():
  39. rconn = glob_cl.r
  40. keys = rconn.keys()
  41. for k in keys():
  42. p(":",k)
  43. p("len(keys)",len(keys))
  44. print("",end="",flush=True)
  45. redis_info()
  46. r"""
  47. def atexit_fn():
  48. pass
  49. # rconn.flushall()
  50. print("ATEXIT FN")
  51. rinfo_len()
  52. keys = rconn.keys()
  53. print(keys)
  54. print(len(keys))
  55. print("t 000")
  56. # time.sleep(10)
  57. print("t 010")
  58. # time.sleep(20)
  59. print("t 020")
  60. print("ATEXIT FN...")
  61. rconn.flushall()
  62. atexit.register(atexit_fn)
  63. # """