From 488a578a1643b32a7390c85cd50f801e479cfb9d Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 23 Jul 2024 18:02:51 +0800 Subject: [PATCH] bugfix --- appPublic/registerfunction.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appPublic/registerfunction.py b/appPublic/registerfunction.py index 5cd71f2..63242b6 100755 --- a/appPublic/registerfunction.py +++ b/appPublic/registerfunction.py @@ -3,6 +3,7 @@ from inspect import isfunction, iscoroutinefunction from functools import partial from appPublic.dictObject import DictObject from appPublic.Singleton import SingletonDecorator +from appPublic.log import info, error @SingletonDecorator class RegisterFunction: @@ -18,11 +19,13 @@ class RegisterFunction: def get(self,name): return self.registKW.get(name,None) - async def exe(name, *args, **kw): + async def exe(self, name, *args, **kw): f = self.get(name) if f is None: + error(f'{name=} function not registed') return None if iscoroutinefunction(f): + info(f'{name=} is coroutine function'); return await f(*args, **kw) return f(*args, **kw) @@ -40,7 +43,10 @@ class RegisterCoroutine: else: self.kw[name].append(func) async def exe(self, name, *args, **kw): - fs = self.kw.get(name).copy() + fs = self.kw.get(name) + if fs is None: + return + fs = fs.copy() fs.reverse() if fs: for f in fs: