sivy / pystatsd

Python implementation of the Statsd client/server
http://pypi.python.org/pypi/pystatsd/
BSD 2-Clause "Simplified" License
358 stars 87 forks source link

Importing in sitecustomize.py breaks python command line #99

Open agibli opened 7 years ago

agibli commented 7 years ago

This is related to a setproctitle issue (which unfortunately is marked closed): https://github.com/dvarrazzo/py-setproctitle/issues/49

Importing pystatsd imports the pystatsd.server module, which attempts to import setproctitle, if it is available.

As a consequence of the linked issue, importing pystats within a sitecustomize.py will cause python to fail to execute scripts with command line arguments (if setproctitle is available):

$ touch test.py
$ echo "import pystatsd" > sitecustomize.py
$ export PYTHONPATH=.:$PYTHONPATH
$ python test.py --some-arg
python test.py --some-arg: can't open file 'test.py --some-arg': [Errno 2] No such file or directory

Absent an upstream fix, it may be worth somehow adding an option to disable use of setproctitle, and/or lazily importing it to work around the issue.

Thanks!