Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does PYTHONOPTIMIZE do in the python interpreter?

I run a python task with supervisor, and when I try to use mutilprocess in the python task.I meet with the error

"File/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 124, in start 

'daemonic processes are not allowed to have children'" 

But that's okay after I execute the command "export PYTHONOPTIMIZE=1" in the terminal .Anyone can tell me what has happened while executing the command "export PYTHONOPTIMIZE=1"

like image 518
DlutAF Avatar asked Sep 14 '25 10:09

DlutAF


1 Answers

Setting the PYTHONOPTIMIZE environment variable to 1 is the same thing as using the -O command line switch:

Remove assert statements and any code conditional on the value of __debug__.

The error message you see is an AssertionError exception; the relevant section of the source code uses assert:

assert not _current_process._daemonic, \
       'daemonic processes are not allowed to have children'

so setting the environment variable only suppresses the assertion. The problem itself doesn't go away.

like image 86
Martijn Pieters Avatar answered Sep 17 '25 01:09

Martijn Pieters