gopidesupavan commented on issue #50185: URL: https://github.com/apache/airflow/issues/50185#issuecomment-2917340184
@kaxil @uranusjr considering the above all discussion this leaves me i guess two options IMHO. Whats your suggestion or thoughts ? 1. Create async version of all the comms methods that access via triggerer 2. Use something like [greenback](https://github.com/oremanj/greenback) , execute the sync version inside greenback portal. this we no need to have copy of async version. For option two i am thinking something like this below we can have decorators on the methods. and if the comms methods called from async function then these executes in greenback portal. for normal sync invocation it works without any issues. ``` lock = aiologic.Lock() global is_async_process is_async_process = False def sync_or_async(func): @functools.wraps(func) def wrapper(*args, **kwargs): if is_async_process: asyncio.get_running_loop() async def async_wrapper(): return await greenback.with_portal_run_sync(func, *args, **kwargs) return async_wrapper() else: return func(*args, **kwargs) return wrapper @sync_or_async def sample_func(a, b): with lock: return a + b async def async_main(): global is_async_process is_async_process = True await sample_func(4, 4) if __name__ == "__main__": sample_func(1, 2) asyncio.run(async_main()) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
