Edgewall Software

Ticket #3781 (closed defect: fixed)

Opened 2 years ago

Last modified 2 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:

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

     
    5454            fd = stream.fileno() 
    5555            flags = fcntl.fcntl(fd, fcntl.F_GETFL) 
    5656            fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK) 
    57     except ImportError: 
     57    except (ImportError, AttributeError): 
    5858        pass 
    5959 
    6060    try: # Use binary I/O on Windows 
    6161        import msvcrt 
    6262        msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) 
    6363        msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) 
    64     except ImportError: 
     64    except (ImportError, AttributeError): 
    6565        pass 
    6666 
    6767    gateway = CGIGateway() 
  • trac/web/_fcgi.py

     
    948948                # Attempt to glean the maximum number of connections 
    949949                # from the OS. 
    950950                maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0] 
    951             except ImportError: 
     951            except (ImportError, AttributeError): 
    952952                maxConns = 100 # Just some made up number. 
    953953            maxReqs = maxConns 
    954954            if multiplexed: 

Attachments

Change History

  Changed 2 years ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned
  • milestone changed from 0.10.1 to 0.10

Looks good to me, except maybe the msvcrt one. It doesn't look like setmode can be missing if msvcrt can be imported...

  Changed 2 years ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r3790.

  Changed 2 years ago by mgood

  • keywords needinfo added
  • status changed from closed to reopened
  • resolution fixed deleted

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   Changed 2 years ago by cboos

  • keywords needinfo removed

Here's what I've found after some research:

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.

in reply to: ↑ 4   Changed 2 years ago by mgood

  • status changed from reopened to closed
  • resolution set to fixed

Replying to cboos:

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

Ok, that seems like a good enough reason.

Add/Change #3781 (Sometimes Trac install crashes on Windows at startup)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.