[Tutor] cgi.FieldStorage() causing thread.error: can't allocate lock

Alan Gauld alan.gauld at btinternet.com
Sun Jun 1 12:20:00 CEST 2014


On 01/06/14 08:05, SABARWAL, SHAL wrote:
> Folks,
>
> Appreciate any more insight into this problem. ?
>
> The error occurs not frequently, and would still like to understand and
> resolve it.

> The calling application(applicationCode.py) has a basic - form =
> cgi.FieldStorage()
>
> I have attached cgi.py, mimetools.py and tempfile.py

The one file you have not shared is yours.
What does applicationCode.py look like?
I know you've told us it has a

form = cgi.FieldStorage()

call within it but it might help to see the context.

Also did you try Dave's suggestion of importing
tempfile in your code before calling the cgi functions.

> The error is pointed out at the import statement as below
>
> File "applicationCode.py", line 4, in <module>
>      import cgi
> File "/usr/local/lib/python2.7/cgi.py", line 51, in <module>
>      import mimetools
>    File "/usr/local/lib/python2.7/mimetools.py", line 6, in <module>
>      import tempfile
>    File "/usr/local/lib/python2.7/tempfile.py", line 83, in <module>
>      _once_lock = _allocate_lock()
>             thread.error: can't allocate lock

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list