[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Converting Python CGI to WSGI scripts

Sebastian Bassi

3/17/2010 5:23:00 AM

On Tue, Mar 16, 2010 at 2:18 PM, <python@bdurham.com> wrote:
> I have a few dozen simple Python CGI scripts.
> Are there any advantages or disadvantages to rewriting these CGI scripts as
> WSGI scripts?

It depends of the script. WSGI should be faster since you don't start
a Python instance for each call (as in CGI).

--
Sebastián Bassi. Diplomado en Ciencia y Tecnología.

Curso de Python en un día: http://bit.ly/c...
Python for Bioinformatics: http://tinyurl.com...

Non standard disclaimer: READ CAREFULLY. By reading this email,
you agree, on behalf of your employer, to release me from all
obligations and waivers arising from any and all NON-NEGOTIATED
agreements, licenses, terms-of-service, shrinkwrap, clickwrap,
browsewrap, confidentiality, non-disclosure, non-compete and
acceptable use policies ("BOGUS AGREEMENTS") that I have
entered into with your employer, its partners, licensors, agents and
assigns, in perpetuity, without prejudice to my ongoing rights and
privileges. You further represent that you have the authority to release
me from any BOGUS AGREEMENTS on behalf of your employer.
2 Answers

John Nagle

3/17/2010 6:34:00 AM

0

Sebastian Bassi wrote:
> On Tue, Mar 16, 2010 at 2:18 PM, <python@bdurham.com> wrote:
>> I have a few dozen simple Python CGI scripts.
>> Are there any advantages or disadvantages to rewriting these CGI scripts as
>> WSGI scripts?
>
> It depends of the script. WSGI should be faster since you don't start
> a Python instance for each call (as in CGI).

It's almost always faster. But be careful about global state.
Remember that WSGI/FCGI programs are really functions, called
over and over with a new transaction on each call. So your
function has to be reusable.

Things like initializing global variables at program load time,
rather than when the main function is called, may give trouble.
Also, be careful about leaving files, database connections, and
sockets open after the main function returns.

John Nagle

python

3/17/2010 8:32:00 PM

0

Sebastian/John,

Thank you very much for your feedback.

John: I initially missed the nuance of WSGI scripts being function
calls. I suspect your tip has saved me a lot of pain :)

Regards,

Malcolm