bugfix
This commit is contained in:
parent
e4b2796f17
commit
1c22efd7a0
@ -39,9 +39,11 @@ class FunctionProcessor(BaseProcessor):
|
|||||||
# globals().update(self.run_ns)
|
# globals().update(self.run_ns)
|
||||||
|
|
||||||
debug(f'params_kw={params_kw}, {args=}')
|
debug(f'params_kw={params_kw}, {args=}')
|
||||||
|
env = {k:v for k,v in self.run_ns.items() if k not in ['params_kw', 'request'] }
|
||||||
|
debug(f'{env=}')
|
||||||
if inspect.iscoroutinefunction(f):
|
if inspect.iscoroutinefunction(f):
|
||||||
return await f(request, params_kw, *args, **self.run_ns)
|
return await f(request, params_kw, *args, **env)
|
||||||
return f(request, params_kw, *args, **self.run_ns)
|
return f(request, params_kw, *args, **env)
|
||||||
|
|
||||||
async def datahandle(self,request):
|
async def datahandle(self,request):
|
||||||
x = await self.path_call(request)
|
x = await self.path_call(request)
|
||||||
|
@ -31,6 +31,7 @@ from appPublic.Singleton import SingletonDecorator
|
|||||||
from appPublic.rc4 import password, unpassword
|
from appPublic.rc4 import password, unpassword
|
||||||
from appPublic.registerfunction import RegisterFunction
|
from appPublic.registerfunction import RegisterFunction
|
||||||
from appPublic.httpclient import HttpClient
|
from appPublic.httpclient import HttpClient
|
||||||
|
from appPublic.log import debug, exception
|
||||||
|
|
||||||
from sqlor.dbpools import DBPools,runSQL,runSQLPaging
|
from sqlor.dbpools import DBPools,runSQL,runSQLPaging
|
||||||
from sqlor.filter import DBFilter, default_filterjson
|
from sqlor.filter import DBFilter, default_filterjson
|
||||||
@ -56,6 +57,7 @@ async def stream_response(request, async_data_generator, content_type='text/html
|
|||||||
res.content_type = content_type
|
res.content_type = content_type
|
||||||
await res.prepare(request)
|
await res.prepare(request)
|
||||||
async for d in async_data_generator():
|
async for d in async_data_generator():
|
||||||
|
try:
|
||||||
if isinstance(d, bytes):
|
if isinstance(d, bytes):
|
||||||
await res.write(d)
|
await res.write(d)
|
||||||
elif isinstance(d, str):
|
elif isinstance(d, str):
|
||||||
@ -63,6 +65,10 @@ async def stream_response(request, async_data_generator, content_type='text/html
|
|||||||
else:
|
else:
|
||||||
d = json.dumps(d, ensure_ascii=False)
|
d = json.dumps(d, ensure_ascii=False)
|
||||||
await res.write(d.encode('utf-8'))
|
await res.write(d.encode('utf-8'))
|
||||||
|
except Exception as e:
|
||||||
|
e = Exception(f'write error{e=}, {d=}')
|
||||||
|
exception(f'{e}\n{format_exc()}')
|
||||||
|
raise e
|
||||||
await res.drain()
|
await res.drain()
|
||||||
await res.write_eof()
|
await res.write_eof()
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user