New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: 'daemonic processes are not allowed to have children', after upgradeing to airflow:2.0.1 #14896
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
same as -> #13298 |
Ok, it works now, but what if I need assertions in my code? Why it worked in earlier versions but not in the current one? Is it going to be fixed? |
I’m running into this same issue (with Celery Executor upgrading to airflow 2.0.1). I’m concerned about the line in the stack overflow explanation for the PYTHONOPTIMIZE fix that says:
What are the possible consequences of ignoring this particular assertion? Are there any updates on why this suddenly broke in 2.0? |
You simply should not use multiprocessing inside Local Executor. This is likely going to break. The assertion is correct and you should likely change your approach |
It broke because of optimisations implemented in airflow that make use of multiprocessing. The best way for you to proceed will be to turn your multiprocessing jobs into separate Airflow tasks |
You can also run your python code using python operator with virtualenv - that launches a new python interpreter and you can launch multiprocessing there. |
Thanks! |
We have the some problem, this worked fine in Airflow 1. I think is important to allow concurrency inside a task, because there are cases when you dont want, from a design perspective, clutter your DAG with a lot of tiny and no-neccesary-to-check-and-control-independently tasks from an workflow managment perspective from the web UI, so you want to do concurrency inside the task. There is nothing to do to fix this? We are using LocalExecutor. |
I got the same error: daemonic processes are not allowed to have children from celery worker when Context:
|
@damon09273 Were you able to resolve this issue? |
@damon09273 @ahazeemi I posted the workaround and solution for |
I had a similar issue using CeleryExecutor and multiprocessing. This may be a side effect of Airflow 2 forking by default to execute tasks versus creating a new Python process, which seems to be one thing that changed from Airflow 1 in CeleryExecutor and LocalExecutor. There's a config value that can control that behavior. I got around the issue by adding execute_tasks_new_python_interpreter = True to my airflow.cfg under [core], and without using PYTHONOPTIMIZE. It looks like CeleryExecutor and LocalExecutor will try to use this value to determine to fork or to subprocess, so maybe that will work for LocalExecutor too. |
@pmlewis Because |
There is a known solution to this problem. Please use I saw already quite a number of confirmations that it works for people with similar problems, and I am just considering making an entry in Best Practices of Airflow to cover that piece (@ashb @kaxil - you might also be interested in that :). This is an interesting finding I had by following up a number of issues and trying to help people. @pmlewis, @damon09273 @ahazeemi @ivanrezic-maistra - if you can also confirm that this solution works, I'd be more confident in adding best practice for that one. |
@potiuk How can I try this? Also I want to feedback a information is that issue didn't happens in Airflow 2.1.3, I'm not sure why, because I didn't set |
Well, I think we are talking about two different issues with "deamonic processes" and this is the source of confusion here.
Even if the error message was the same, those two issues have very different root cause, and while they were somewhat hijacked here - the error 1) still requires the So answering the question @damon09273 - it's fine for you now. but if someone tries to use local executor and do multi-processing in their custom code within Python Operator (or writes a custom operator) then |
@potiuk Thanks! |
@potiuk I believe there is on task to do on this issue? can we close? |
Agree. |
Hi team, apologies for adding to a closed thread. I encountered the same problem when using a
I am using Airflow 2.3.3 and Celery 5.2.7 running on the default |
This is the question on how you are deploying Airflow and whether you run the worker with daemon flag: https://github.com/apache/airflow/blob/main/airflow/cli/commands/celery_command.py#L180 I believe you can run airflow worker as non-daemon - with all the caveats that you have to take care of - like handling stdin/out, signals, switching working directory and everything elas that "daemonizing" does https://manpages.ubuntu.com/manpages/bionic/man1/daemonize.1.html |
Thanks for your response! Unfortunately, I believe the issue is related to how the Celery Worker itself handles concurrency, regardless of the daemonic flag on the worker command itself. Looking more in to it I think my choices are
|
Yeah. This is actually quite likely.
|
|
Apache Airflow version: 2.0.1
Kubernetes version (if you are using kubernetes) (use
kubectl version
): /Environment:
uname -a
): Linux ivan-pc 5.4.0-66-generic Improvement in task documentation capabilities #74~18.04.2-Ubuntu SMP Fri Feb 5 11:17:31 UTC 2021 x86_64 x86_64 x86_64 GNU/LinuxWhat happened:
I am using LocalExecutor, and I was using it on Apache/Airflow 1.10.12 the same way. I mean I had one PythonOperator which runs python method which runs multiprocessing job using ProcessPoolExecutor (concurrent.futures). And on earlier version it ran successfully without any problems, but now I get this error:
What you expected to happen:
I expected it to run as it was running on Airflow 1.10.12
How to reproduce it:
Run airflow using docker-compose like this:
And inside run python operator which runs ProcessPoolExecutor from concurrent.futures
Anything else we need to know:
This problem occurs every time I run python operator with multiprocessing. I have searched everywhere without any luck. There seems to be a similar error when using Celery Executor but it doesn't help (as I am using LocalExecutor) and there is no import collisions.
The text was updated successfully, but these errors were encountered: