Opened 18 years ago
Closed 18 years ago
#3781 closed defect (fixed)
Sometimes Trac install crashes on Windows at startup
Reported by: | pkou at ua.fm | Owned by: | Christian Boos |
---|---|---|---|
Priority: | high | Milestone: | 0.10 |
Component: | general | Version: | 0.10rc1 |
Severity: | critical | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Environment: Clean Trac install from source:/trunk@3787 on Windows XP and typical CGI configuration via Apache 2.0.55.
Problem: The system crashes while accessing Trac with the following details:
Oops... Trac detected an internal error: 'module' object has no attribute 'fcntl' Traceback (most recent call last): File "C:/Program Files/Apache Group/Apache2/cgi-bin/trac.cgi", line 20, in ? cgi_frontend.run() File "C:\Python23\Lib\site-packages\trac\web\cgi_frontend.py", line 55, in run flags = fcntl.fcntl(fd, fcntl.F_GETFL) AttributeError: 'module' object has no attribute 'fcntl'
Reason: The specified place is protected from not existing modules using ImportError
. However, it is not protected from the cases when the specific module exists but it does not have the required symbols.
Solution is proposed in the following patch:
-
trac/web/cgi_frontend.py
54 54 fd = stream.fileno() 55 55 flags = fcntl.fcntl(fd, fcntl.F_GETFL) 56 56 fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK) 57 except ImportError:57 except (ImportError, AttributeError): 58 58 pass 59 59 60 60 try: # Use binary I/O on Windows 61 61 import msvcrt 62 62 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) 63 63 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) 64 except ImportError:64 except (ImportError, AttributeError): 65 65 pass 66 66 67 67 gateway = CGIGateway() -
trac/web/_fcgi.py
948 948 # Attempt to glean the maximum number of connections 949 949 # from the OS. 950 950 maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0] 951 except ImportError:951 except (ImportError, AttributeError): 952 952 maxConns = 100 # Just some made up number. 953 953 maxReqs = maxConns 954 954 if multiplexed:
Attachments (0)
Change History (5)
comment:1 by , 18 years ago
Milestone: | 0.10.1 → 0.10 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 18 years ago
Keywords: | needinfo added |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
The module fcntl
should not be available on Windows. The docs specifically list "Availablility: Unix" for the module, not specific functions: http://docs.python.org/lib/module-fcntl.html
I just tested Python 2.3, 2.4, and 2.5 on Windows and this module is not available on any of these. So, I'd kind of like to know what's really going on here before we just throw on a patch.
follow-up: 5 comment:4 by , 18 years ago
Keywords: | needinfo removed |
---|
Here's what I've found after some research:
- http://pydoc.org/get.cgi/usr/lib/python2.2/FCNTL.py
- http://mail.python.org/pipermail/python-dev/2004-July/046322.html
From other references, it looks like some Windows 2.3 installations still have a fcntl.pyc in their Python23\Lib…
I think that r3790 doesn't "hurt" that much, and if it helps Trac to work out-of-the-box even on those "broken" installations, I'd say we should keep it.
comment:5 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Replying to cboos:
Here's what I've found after some research:
Ok, that seems like a good enough reason.
Looks good to me, except maybe the
msvcrt
one. It doesn't look likesetmode
can be missing ifmsvcrt
can be imported…