gopidesupavan commented on issue #50185: URL: https://github.com/apache/airflow/issues/50185#issuecomment-2912628296
> Also note that the different APIs that aiologic provides should not be mixed in the same thread if threading is used for the green (sync) API. This is a fundamental problem due to the fact that primitives work at the task level: `lock.green_acquire()` can block the event loop when `aiologic.lowlevel.current_green_library() == "threading"`, and as a result lock will never be released. This is well demonstrated in the following example: > > example.py > This is the same as using `threading.Lock` along with asyncio tasks. If you have such calls somewhere, it can be the cause of deadlocks. > > This problem of mixing two APIs in the same thread can be solved by using [GLock](https://gist.github.com/x42005e1f/a50d0744013b7bbbd7ded608d6a3845b), which can be a thread-level lock - if you use the read-preferring readers-writer locks condition (`self.group is None or self.group == group`), its APIs can safely mix (just replace `lock = aiologic.Lock()` with `lock = GLock(default_group_factory=current_thread_ident)` and that example will work without hanging). However, since it would no longer be a task level, it would not be coroutine-safe. looks like we are using that similar way some places. this is async one https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/jobs/triggerer_job_runner.py#L965 and in other places we are using like `with SUPERVISOR_COMMS.lock:` BTW GLock where can i find this package i dont see it on PyPI? i will try with this -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org