I running apache with mod_fastcgi to run python scripts (using Ubuntu OS).
How can I debug python with fastcgi? I put a pdb.set_trace() call in my script, but when loading the page in a browser nothing happens in the console from which I ran the apache start command (/etc/init.d/apache2 start).
Where should the python debugger run??
Dan
You have to attach pdb to a running instance of your FCGI script, read this for a How To.
This information is also stated in the FCGI FAQ.
Related
I use PyDev with Eclipse as an IDE.
How can I debug a tornado server running inside a docker container using PyDev/Eclipse?
Is it possible to put breakpoints in PyDev/Eclipse and debug like a server running natively on my machine?
One option is using the remote debugger, so, you can add connect the running program to the Eclipse remote debugger (see http://www.pydev.org/manual_adv_remote_debugger.html). The only thing here is that it has to create a connection from the container to the host.
Another thing which could work (as in: I've never tested it) is creating an interpreter which always runs inside docker... an interpreter in PyDev can be any executable (such as a .sh), so, you can try making a script which will run python inside docker by default (although as I never tested this I can't say how well that'll work).
I have an installed free account on Heroku to get started.
A python code that accepts web requests is starting a shell subprocess, does starting this subprocess count and need a dyno?
I am seeing this specific code not do its intended purpose, but when run through the shell on Heroku it does what it is supposed too.
I'm developing a cassandra storage finder for graphite-api.
graphite-api is installed via pip and run via gunicorn so I can't just call the script with a debugger but want to use interactive debugging.
When I import pdb in my storage finder and set a breakpoint, the code will halt there, but how can I connect now to the headless running pdb in the script?
Or is my approach to this debugging problem the wrong one and this has to be done in a completely other way?
pdb gives control over to gunicorn, which is not what you want. Have a look at rpdb or other remote debugging solutions.
I'm using Community Edition PyCharm 4.5.1 and I'm developing CGI python scripts. My needs are to start the debugger and attach the script (then break to the first breakpoint) once it is called by my HTTP client.
I don't know if I can, I hope. Everything works fine, from the Python server to the HTML/JavaScript code that calls my CGI script. Also, I'm perfectly able to debug a Python script I just start normally. But now the problem is that it is the HTTP server that starts the script, neither me (from command line) nor the debugger itself.
Any idea? Thanks!
AFAIK, you just put into your script
import cgitb
cgitb.enable()
print "Content-type: text/html\n\n"
and it's being debugged by itself.
I have meet the same problem as yours when i use pycharm on CentOS, but i found pycharm can attach to cgi script automaticly on windows, so i try to follow the source code of CGIRequestHandler, I found there is a difference in CGIRequestHandler.run_cgi() function, it will use fork on linux, and subprocess on windows, so i guess may be these two different ways of creating child process leading to different result. so i try the following code, force it subprocess on linux, and it works!
CGIHTTPRequestHandler.have_fork = 0
httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
I have a website in Django1.1.1 deployed in Apache2.0. In the backend I have a launcher script that starts three python processes that interact with the frontend. One of these processes uses a Windows Event (using CreateEvent) that communicates with Apache.
My problem is that when I run the launcher script first and then start Apache everything seems to be working fine, but when I start Apache first and then run launcher the process with the Windows event is never launched. On starting the process on command line it dies with the error
pywintypes.error: (5, 'CreateEvent', 'Access is denied.')
I think this is a permission issue where Apache is running as SYSTEM user and the launcher running as me. Any ideas how I can fix this?
It could be something else too, any ideas?
I am a noob on Windows so please bear with me. BTW I am using Windows XP and python 2.4
Thanks
S
UPDATE:
I eventually used python recipe Controlling Windows Services to always launch Apache service post my script. My problem is resolved!
Are you specifying a security descriptor in the call to CreateEvent (through the lpEventAttributes argument)?
See the section 5 (Synchronization Object Security and Access Rights) on the following page for details:
Processes and Threads: Synchronization