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.

tasks_loop.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. rconn.flushall()
  46. redis_info()
  47. r"""
  48. def atexit_fn():
  49. pass
  50. # rconn.flushall()
  51. print("ATEXIT FN")
  52. rinfo_len()
  53. keys = rconn.keys()
  54. print(keys)
  55. print(len(keys))
  56. print("t 000")
  57. # time.sleep(10)
  58. print("t 010")
  59. # time.sleep(20)
  60. print("t 020")
  61. print("ATEXIT FN...")
  62. rconn.flushall()
  63. atexit.register(atexit_fn)
  64. # """