#13336 closed defect (fixed)
tracd 1.5.2 --daemonize fails, "TypeError: an integer is required (got type str)"
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.3 |
Component: | general | Version: | 1.5.2 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Fixed |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
[17483/trunk/trac/util/daemon.py] changed daemonize from open to os.open, but didn't convert from Python 'rb' and 'ab+' to os.open flags, result of trying to run tracd -d is:
Traceback (most recent call last): File "/usr/local/bin/tracd", line 11, in <module> load_entry_point('Trac==1.5.2', 'console_scripts', 'tracd')() File "/usr/local/lib/python3.8/site-packages/trac/web/standalone.py", line 366, in main daemon.daemonize(pidfile=args.pidfile, progname='tracd', File "/usr/local/lib/python3.8/site-packages/trac/util/daemon.py", line 71, in daemonize stdin = os.open(stdin, 'rb') TypeError: an integer is required (got type str)
Attachments (0)
Change History (5)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|---|
Milestone: | → 1.5.3 |
comment:2 by , 4 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 4 years ago
Ah, the changes in [d373b6ded/jomae.git] (log:jomae.git@1.5-py3) was incomplete.
The intention of the using os.open()
is that avoiding text/binary mode for built-in open()
because it just wants to get file descriptors for os.dup2()
with std{in,out,err}
.
Of course, your suggested changes are correct.
-
trac/util/daemon.py
diff --git a/trac/util/daemon.py b/trac/util/daemon.py index cc7c0d61e..7b49bcfdf 100644
a b def daemonize(pidfile=None, progname=None, stdin='/dev/null', 68 68 # The process is now daemonized, redirect standard file descriptors 69 69 for stream in sys.stdout, sys.stderr: 70 70 stream.flush() 71 stdin = os.open(stdin, 'rb') 72 stdout = os.open(stdout, 'ab+') 73 stderr = os.open(stderr, 'ab+', 0) 74 os.dup2(stdin.fileno(), sys.stdin.fileno()) 75 os.dup2(stdout.fileno(), sys.stdout.fileno()) 76 os.dup2(stderr.fileno(), sys.stderr.fileno()) 71 stdin = os.open(stdin, os.O_RDONLY) 72 stdout = os.open(stdout, os.O_RDWR | os.O_APPEND) 73 stderr = os.open(stderr, os.O_RDWR | os.O_APPEND) 74 os.dup2(stdin, sys.stdin.fileno()) 75 os.dup2(stdout, sys.stdout.fileno()) 76 os.dup2(stderr, sys.stderr.fileno()) 77 for fd in (stdin, stdout, stderr): 78 os.close(fd) 77 79 78 80 if pidfile: 79 81 # Register signal handlers to ensure atexit hooks are called on exit
comment:4 by , 4 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks, Jun. Fixed in r17497.
comment:5 by , 4 years ago
Owner: | changed from | to
---|
os.open
requires integer flags. This change seems to work. What do you think, Jun?trac/util/daemon.py
s.open(stdin, 'rb')s.open(stdout, 'ab+')s.open(stderr, 'ab+', 0)I tried switching to integer flags for
os.open
, but then: