Ticket #3781 (closed defect: fixed)
Opened 5 years ago
Last modified 5 years ago
Sometimes Trac install crashes on Windows at startup
| Reported by: | pkou at ua.fm | Owned by: | cboos |
|---|---|---|---|
| Priority: | high | Milestone: | 0.10 |
| Component: | general | Version: | 0.10rc1 |
| Severity: | critical | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API 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
Change History
comment:1 Changed 5 years ago by cboos
- Milestone changed from 0.10.1 to 0.10
- Owner changed from jonas to cboos
- Status changed from new to assigned
comment:2 Changed 5 years ago by cboos
- Resolution set to fixed
- Status changed from assigned to closed
Fixed in r3790.
comment:3 Changed 5 years ago by mgood
- Keywords needinfo added
- Resolution fixed deleted
- Status changed from closed to 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.
comment:4 follow-up: ↓ 5 Changed 5 years ago by cboos
- 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 in reply to: ↑ 4 Changed 5 years ago by mgood
- Resolution set to fixed
- Status changed from reopened to 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 like setmode can be missing if msvcrt can be imported...