Procházet zdrojové kódy

auto commit

master
jfinn před 2 roky
rodič
revize
3e1819abbd
1 změnil soubory, kde provedl 6 přidání a 108 odebrání
  1. 6
    108
      wsps/tasks_loop.py

+ 6
- 108
wsps/tasks_loop.py Zobrazit soubor

@@ -13,11 +13,6 @@ import atexit
13 13
 from asgiref.sync import async_to_sync,sync_to_async
14 14
 
15 15
 
16
-'''
17
-	umod
18
-# '''
19
-
20
-
21 16
 
22 17
 p=print
23 18
 
@@ -29,15 +24,6 @@ def connect_redis1():
29 24
 	return redis.Redis(host='localhost', port=6379, db=1,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace")
30 25
 def connect_redis():
31 26
 	return redis.Redis(host='localhost', port=6379, db=0,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace")
32
-	# return redis.Redis(host='localhost', port=6379,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace")
33
-	r'''
34
-
35
-	return {
36
-	 "rconn0":redis.Redis(host='localhost', port=6379, db=0,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace"),
37
-	 "rconn1":redis.Redis(host='localhost', port=6379, db=1,charset="utf-8", decode_responses=True, encoding_errors="backslashreplace"),
38
-	}
39
-	# '''
40
-
41 27
 
42 28
 
43 29
 def eclass_factory(n):
@@ -49,9 +35,6 @@ def eclass_factory(n):
49 35
 	return ret
50 36
 
51 37
 
52
-'''
53
-# '''
54
-
55 38
 
56 39
 
57 40
 
@@ -68,14 +51,9 @@ def callable_helper(fn):
68 51
 
69 52
 
70 53
 
71
-
72
-
73
-
74
-
75
-
76
-
77
-verbose = print
54
+# verbose = print
78 55
 verbose=nop
56
+
79 57
 class DbgMixin:
80 58
 	async def ws_rec(self,text_data,*a,**kw):
81 59
 		# if "dbg" in 
@@ -87,9 +65,7 @@ class DbgMixin:
87 65
 class AconMixin(DbgMixin):
88 66
 # class AconMixin:
89 67
 	async def connect(self):
90
-		# print("-----------CONNECTING async def connect")
91
-		# p("ACON!!!!!!!!!!!!!!!!!!!!!!!!!!!")
92
-		p(flush=True)
68
+		p(end="",flush=True)
93 69
 		await self.accept()
94 70
 		verbose("<MRO")
95 71
 
@@ -98,14 +74,11 @@ class AconMixin(DbgMixin):
98 74
 		await self.call_all_mro("ws_conn")
99 75
 		await self.call_all_mro("ws_conn2")
100 76
 		verbose("/MRO>")
101
-		# await self.ws_conn_once(event)		
102 77
 		await self.ws_conn_once()	   
103 78
 	async def ws_conn_once(self, *a,**kw):pass
104 79
 	async def ws_disconn_once(self, *a,**kw):pass
105 80
 	async def ws_rec_once(self, *a,**kw):pass
106 81
 	async def receive(self, *a,**kw):
107
-		# print("REC")
108
-		# print("-----------REC")
109 82
 		await self.call_all_mro("ws_rec",*a,**kw)
110 83
 		await self.ws_rec_once(*a,**kw)
111 84
 		print("",end="",flush=True)
@@ -114,26 +87,15 @@ class AconMixin(DbgMixin):
114 87
 		called = set([None])
115 88
 		for cls_obj in self.__class__.__mro__:
116 89
 			mthd = getattr(cls_obj,mthd_name,None)
117
-			# print("~",cls_obj,mthd)
118 90
 			if not mthd in called:
119
-				# print(cls_obj,mthd)
120 91
 				called.add(mthd)
121 92
 				await mthd(self,*args,**kwargs) 
122 93
 	async def disconnect(self, close_code):
123 94
 		await self.call_all_mro("ws_disconn",close_code)
124 95
 		await self.ws_disconn_once(close_code)	  
125
-	async def websocket_connect_x(self, event):
126
-		await super().websocket_connect(event)
127
-		print("<MRO")
128
-		print(type(self))
129
-		await self.call_all_mro("ws_conn",event)
130
-		await self.call_all_mro("ws_conn2",event)
131
-		print("/MRO>")
132
-		await self.ws_conn_once(event)
133 96
 
134 97
 class AclTaskMixin:
135 98
 	async def ws_disconn(self,*a,**kw):
136
-		# for group in self.groups_set:
137 99
 		pass
138 100
 
139 101
 	async def ws_conn0(self):
@@ -141,13 +103,9 @@ class AclTaskMixin:
141 103
 		if glob_cl.has_cl:
142 104
 			return
143 105
 		glob_cl.has_cl = True
144
-		print("AclTaskMixin:ws_conn0")
145 106
 		glob_cl.run_persistent_loop(self)
146 107
 		glob_cl.acl = self.channel_layer
147
-		# print("++++++++++++++++++++++++++")
148
-	async def ws_conn_once(self,*a,**kw):
149
-		pass
150
-		# print("\t\tws_conn_once:","AclTaskMixin")
108
+
151 109
 
152 110
 
153 111
 
@@ -176,15 +134,12 @@ Mixins.AconMixin = AconMixin
176 134
 Mixins.AclTaskMixin = AclTaskMixin
177 135
 
178 136
 
179
-# GCLMixin
180 137
 class globCL(GCLMixin):
181 138
 
182 139
 	def __init__(self,*a,**kw):
183 140
 		# for now we are not going to do any weird class stuff
184 141
 		self.acl = None
185
-		self.has_cl = False
186
-		# rconns = connect_redis()
187
-		self.rconn1 = connect_redis1()
142
+		self.has_cl = False		self.rconn1 = connect_redis1()
188 143
 		self.rconn = connect_redis()
189 144
 		self.rman = RldMan()
190 145
 		self.cbs_once = []
@@ -209,16 +164,11 @@ class globCL(GCLMixin):
209 164
 								await v({k,self})
210 165
 							else:
211 166
 								v({k,self})
212
-
213 167
 						else:
214 168
 							pass
215
-						# p(k,v)
216
-
217
-						pass
218 169
 					except Exception as e:
219 170
 						p("persistent_fast_cb_loop Exception cbs_once:",e)
220 171
 						p(flush=True)
221
-						# raise
222 172
 					else:
223 173
 						pass
224 174
 					finally:
@@ -227,33 +177,24 @@ class globCL(GCLMixin):
227 177
 			await asyncio.sleep(self.fast_timeout)
228 178
 	async def persistent_loop(self,*a,**kw):
229 179
 		while 1:
230
-			# p("PL:",time.time(),flush=1)
231
-			# await asyncio.sleep(5)
232
-			# for k,v in cls.cbs.items():
233 180
 			for k,v in [*self.cbs.items()]:
234 181
 				try:
235 182
 					call_info = callable_helper(v)
236 183
 					if (call_info["is_callable"]):
237 184
 						if call_info["is_coroutine"]:
238
-							pass
239 185
 							await v({k,self})
240 186
 						else:
241 187
 							v({k,self})
242
-
243 188
 					else:
244 189
 						pass
245
-					# p(k,v)
246
-
247 190
 					pass
248 191
 				except Exception as e:
249 192
 					p("persistent_loop Exception",e)
250 193
 					p(flush=True)
251
-					# raise
252 194
 				else:
253 195
 					pass
254 196
 				finally:
255 197
 					pass
256
-			# cbs_once
257 198
 			cbs_once = [*self.cbs_once,*self.cbs_once_set]
258 199
 			self.cbs_once = []
259 200
 			self.cbs_once_set = set()
@@ -270,13 +211,9 @@ class globCL(GCLMixin):
270 211
 
271 212
 					else:
272 213
 						pass
273
-					# p(k,v)
274
-
275
-					pass
276 214
 				except Exception as e:
277 215
 					p("persistent_loop Exception cbs_once:",e)
278 216
 					p(flush=True)
279
-					# raise
280 217
 				else:
281 218
 					pass
282 219
 				finally:
@@ -332,7 +269,7 @@ class RldMan(RldManMixin):
332 269
 		# "dflt_scope":{"globals":globals(),"locals":{}}
333 270
 		}
334 271
 		self.scopes['current_scope'] = self.scopes['dflt_scope_zloc']
335
-		# self.scope_opt = "locals"
272
+		# self.scope_opt = ""locals
336 273
 		self.scope_opt = "globals"
337 274
 		self.print_tb = 0
338 275
 
@@ -418,34 +355,24 @@ class RldMan(RldManMixin):
418 355
 						traceback.print_tb(e.__traceback__,file=sys.stdout)
419 356
 				else:
420 357
 					pass
421
-					# print("ELSE")
422 358
 				finally:
423
-					# print("FINALLY")
424 359
 					pass
425 360
 				print(end="",flush=True)
426 361
 		return ret
427 362
 
428 363
 
429 364
 	def rld_files(self):
430
-		# p()
431
-
432 365
 		ret = {
433 366
 		"errs":{},
434 367
 		"all":{},
435 368
 		"alle":{},
436 369
 		}
437
-		
438
-
439
-
440
-		# for k in self.files:
441 370
 		for k in [*self.files]:
442 371
 			self.rld_file(k,ret)
443
-		# p("rld_files!")
444 372
 		p("",end="",flush=True)
445 373
 		return ret
446 374
 
447 375
 def fn1(*a,**kw):
448
-	# rld_files
449 376
 	glob_cl.rman.rld_files()
450 377
 glob_cl =  globCL()
451 378
 
@@ -453,35 +380,6 @@ glob_cl =  globCL()
453 380
 glob_cl.rman.rld_files()
454 381
 
455 382
 
456
-
457
-
458
-# print("..",end="\n",flush=True)
459
-
460
-
461
-r"""
462
-
463
-def atexit_fn():
464
-	pass
465
-	# rconn.flushall()
466
-	print("ATEXIT FN")
467
-	rinfo_len()
468
-	keys = rconn.keys()
469
-	print(keys)
470
-	print(len(keys))
471
-	print("t 000")
472
-	# time.sleep(10)
473
-	print("t 010")
474
-	# time.sleep(20)
475
-	print("t 020")
476
-	print("ATEXIT FN...")
477
-	rconn.flushall()
478
-atexit.register(atexit_fn)
479
-
480
-
481
-
482
-# """
483
-
484
-
485 383
 def atexit_fn():
486 384
 	print("atexit_fn!\n\n")
487 385
 	rconn = glob_cl.rconn

Načítá se…
Zrušit
Uložit