LNST-project / lnst

Linux Network Stack Test
GNU General Public License v2.0
73 stars 33 forks source link

lnst-slave deamonize parameter does not work on python3 #191

Open jtluka opened 6 years ago

jtluka commented 6 years ago
[root@localhost ~]# lnst-slave -e
Loading config file '/etc/lnst-slave.conf'
2018-10-11 11:22:12       (localhost)        -    INFO: Started
2018-10-11 11:22:12       (localhost)        -    INFO: Using RPC port 9999.
Traceback (most recent call last):
  File "/usr/local/bin/lnst-slave", line 102, in <module>
    main()
  File "/usr/local/bin/lnst-slave", line 98, in main
    daemon.daemonize()
  File "/usr/local/lib/python3.6/site-packages/lnst/Common/Daemon.py", line 56, in daemonize
    pid = self._read_pid()
  File "/usr/local/lib/python3.6/site-packages/lnst/Common/Daemon.py", line 28, in _read_pid
    handle = file(self._pidfile, "r")
NameError: name 'file' is not defined

Replacing 'file' with 'open' should fix the issue.

antonioromito commented 4 years ago

I get this on my FC31.

# lnst-slave -e
Loading config file '/etc/lnst-slave.conf'
2019-11-25 17:43:21       (localhost)        -    INFO: Started
2019-11-25 17:43:21       (localhost)        -    INFO: Using RPC port 9999.
2019-11-25 17:43:21       (localhost)        -    INFO: deamonized with pid 433188
Traceback (most recent call last):
  File "/usr/local/bin/lnst-slave", line 4, in <module>
    __import__('pkg_resources').run_script('lnst===14-8d972d0f5098b5d635677aa3af15234b9a06ea01', 'lnst-slave')
  File "/root/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/root/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1453, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.7/site-packages/lnst-14_8d972d0f5098b5d635677aa3af15234b9a06ea01-py3.7.egg/EGG-INFO/scripts/lnst-slave", line 102, in <module>
    main()
  File "/usr/local/lib/python3.7/site-packages/lnst-14_8d972d0f5098b5d635677aa3af15234b9a06ea01-py3.7.egg/EGG-INFO/scripts/lnst-slave", line 98, in main
    daemon.daemonize()
  File "/usr/local/lib/python3.7/site-packages/lnst-14_8d972d0f5098b5d635677aa3af15234b9a06ea01-py3.7.egg/lnst/Common/Daemon.py", line 91, in daemonize
    se = open("/dev/null", 'a+', 0)
ValueError: can't have unbuffered text I/O
jtluka commented 4 years ago

Hi Antonio. I get the same on Fedora 29.

It seems that buffering cannot be set for files opened in text mode in python3. The documentation says that it's possible to set line buffering instead (buffering=1).