From 660480a821ddf38e200fee7fefbd7451dad20950 Mon Sep 17 00:00:00 2001 From: nggit <12218311+nggit@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:56:01 +0700 Subject: [PATCH 1/2] fix when __globals__.py doesn't exist --- httpout/httpout.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/httpout/httpout.py b/httpout/httpout.py index 84ef0a6..8ab8d7a 100644 --- a/httpout/httpout.py +++ b/httpout/httpout.py @@ -44,8 +44,10 @@ async def _on_worker_start(self, **worker): sys.path.insert(0, document_root) # provides __globals__, a worker-level context - worker['__globals__'] = new_module('__globals__') + module = new_module('__globals__') + worker['__globals__'] = module or ModuleType('__globals__') worker['modules'] = {'__globals__': worker['__globals__']} + py_import = builtins.__import__ def wait(coro, timeout=None): return asyncio.run_coroutine_threadsafe(coro, loop).result(timeout) @@ -77,8 +79,6 @@ def load_module(name, globals, level=0): return module - py_import = builtins.__import__ - def ho_import(name, globals=None, locals=None, fromlist=(), level=0): if (name not in sys.builtin_module_names and globals is not None and '__file__' in globals and @@ -147,17 +147,15 @@ def ho_import(name, globals=None, locals=None, fromlist=(), level=0): return py_import(name, globals, locals, fromlist, level) builtins.__import__ = ho_import + builtins.__globals__ = worker['__globals__'] g.wait = wait g.caches = {} g.executor = MultiThreadExecutor(thread_pool_size) g.executor.start() - if worker['__globals__']: - builtins.__globals__ = worker['__globals__'] - exec_module(worker['__globals__']) - else: - builtins.__globals__ = ModuleType('__globals__') + if module: + exec_module(module) async def _on_worker_stop(self, **worker): g = worker['globals'] From e57377f3bc0eef582072b201c9ba123fe28cad05 Mon Sep 17 00:00:00 2001 From: nggit <12218311+nggit@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:04:54 +0700 Subject: [PATCH 2/2] release 0.0.54 --- httpout/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpout/__init__.py b/httpout/__init__.py index c5bbce9..e0eb7f2 100644 --- a/httpout/__init__.py +++ b/httpout/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2024 nggit -__version__ = '0.0.53' +__version__ = '0.0.54' __all__ = ('HTTPOut',) from .httpout import HTTPOut # noqa: E402