[reportlab-users] Intermittent failure to find font, followed by IOError

Stevens, Ian IStevens at globeandmail.com
Wed Nov 4 14:17:55 EST 2009


I'll see if I can replicate this by creating two Apache sites, each with a different ServerName, and hitting them both. If so, I'll set the same PythonInterpreter for both and see if the error goes away. It's a long-shot, but it's a quick enough test.

Ian.


> -----Original Message-----

> From: Stevens, Ian

> Sent: November 4, 2009 2:10 PM

> To: 'For users of Reportlab open source software'

> Subject: RE: [reportlab-users] Intermittent failure to find

> font, followed by IOError

>

> Thanks Robin. This link may shed some light:

>

> http://www.modpython.org/live/current/doc-html/pyapi-interps.html

>

> Specifically,

>

> "Note that if any third party module is being used which has

> a C code component that uses the simplified API for access to

> the Global Interpreter Lock (GIL) for Python extension

> modules, then the interpreter name must be forcibly set to be

> 'main_interpreter'. This is necessary as such a module will

> only work correctly if run within the context of the first

> Python interpreter created by the process. If not forced to

> run under the 'main_interpreter', a range of Python errors

> can arise, each typically referring to code being run in

> restricted mode."

>

> Also:

>

> "Default behaviour is to name interpreters using the Apache

> virtual server name (ServerName directive). This means that

> all scripts in the same virtual server execute in the same

> subinterpreter, but scripts in different virtual servers

> execute in different subinterpreters with completely separate

> namespaces."

>

> We are using the same codebase for several different domain

> names. I suppose it is possible that some objects are being

> shared across domains, and subsequently over interpreters as

> well. It might be a coincidence, but over 95% of the URLs

> which generate these errors are on the same subdomain even

> though they account for nowhere near 95% of the traffic.

>

> Ian.

>

> > -----Original Message-----

> > From: reportlab-users-bounces at lists2.reportlab.com

> > [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of

> > Robin Becker

> > Sent: November 4, 2009 5:37 AM

> > To: For users of Reportlab open source software

> > Subject: Re: [reportlab-users] Intermittent failure to find font,

> > followed by IOError

> >

> > Stevens, Ian wrote:

> > > Hi Robin. Thanks for the patch. It's been applied, and now

> > we get the following:

> > >

> > > File

> > "/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics

> > .py", line 79, in parseAFMFile

> > > lines = open_and_readlines(afmFileName, 'r')

> > >

> > > File

> > "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py",

> > line 462, in open_and_readlines

> > > return open_and_read(name,mode).split('\n')

> > >

> > > File

> > "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py",

> > line 459, in open_and_read

> > > return open_for_read(name,mode).read()

> > >

> > > File

> > "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py",

> > line 454, in open_for_read

> > > dbg.dump()

> > >

> > > File

> > "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py",

> > line 810, in dump

> > > f = open(self.fn,'wb')

> > >

> > > IOError: file() constructor not accessible in

> > restricted mode, while looking for faceName='AGFScalaSansBold'

> > >

> > > The faceName matches one which is registered before any

> > other PDF work is done. The IOError is the DebugMemo.dump()

> failing.

> > I've never seen that error before. Could it be another

> symptom of the

> > same issue? The original open() for the font could be raising this

> > error. Could it be a side-effect of a mod_python configuration?

> > >

> > I think you're right; if open (ie alias of file) is not availble in

> > the dump then it might well be the problem in the original open.

> >

> > Googling for the error message "IOError: file() constructor not

> > accessible in restricted mode" seems to indicate that it might be

> > related to rexec/mod_python.

> >

> > This link seems to bear out my opinion that Python restricted mode

> > ought to be considered useless

> >

> > http://www.dalkescientific.com/writings/diary/archive/2008/03/

> > 03/restricted_python.html

> >

> > this email

> >

> > http://www.modpython.org/pipermail/mod_python/2004-April/015476.html

> >

> > seems to imply this has been seen in mod_python land before.

> > I think the implication of the latter is that code is being

> executed

> > in the wrong thread. I will try asking about this on clp.

> >

> >

> >

> > > FYI, we're running Python 2.5.2 and mod_python 3.3.1.

> > >

> > > Thanks,

> > > Ian.

> > >

> > >.......

> > --

> > Robin Becker

> > _______________________________________________

> > reportlab-users mailing list

> > reportlab-users at lists2.reportlab.com

> > http://two.pairlist.net/mailman/listinfo/reportlab-users

> >



More information about the reportlab-users mailing list