CGIHTTPServer threading problems
I'm a simple python webserver based on CGIHTTPServer module: import CGIHTTPServer import BaseHTTPServer import SocketServer import sys import SQL,network from config import * class ThreadingServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer): pass cfg = params() print XBOX Server started on port %s. Press Ctrl+C to kill Server % cfg.port server = ThreadingServer((cfg.name,cfg.port),CGIHTTPServer.CGIHTTPRequestHandler) try: while 1: sys.stdout.flush() server.handle_request() except KeyboardInterrupt: print Server killed The my cgi scripts are stored in the cgi-bin folder. One cgi script in particular implements multi-threading and is supposed to be asynchronous but it's not working. The browser that requests on the cgi script tends to wait until the cgi script is done. I checked multi-threaded cgi script but I'm 100% percent sure that it has no problem since it worked as a mod_python script before. Anyone came across with this problem? -- http://mail.python.org/mailman/listinfo/python-list
Obtaining the remote ip address
One quick question: I have a python cgi script running behind a CGI server which is also built using python using CGIHTTPServer module. How can my cgi script obtain the remote ip address? -- http://mail.python.org/mailman/listinfo/python-list
Re: Obtaining the remote ip address
Thanks a lot Justin! ^_^ -- http://mail.python.org/mailman/listinfo/python-list
Threading.Lock() question
I have a multithreaded application that spawns threads which query a database server. During stress test I encountered some threads failing due lost connection errors and sometimes the actual script itself dies due to a Segmentation Fault. I realized that it might be a deadlock situation so I applied a lock mechanism but after another stress test, some threads are still failing. Here's a rough sketch of my script: class Process(threading.Thread): def __init__(self,lock,query) self.lock = lock self.query = query threading.Thread.__init__(self) def run(self): ''' Some data processing code here ''' self.lock.acquire() result = cursor.execute(query) self.lock.release() class Send(Request__POA.Send): def push(self,query,...some args here): lock = threading.Lock() Process(lock,query).start() db = MySQL().connect() cursor = db.make_cursor() The class Send is being called by a CORBA client. The script is actually a CORBA server which in the future would serve a high traffic of requests. Is my usage is locking correct or am I doing something stupid in the code? Thanks is advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading.Lock() question
I think I just found out my problem. How stupid of me, I should've created an instance of lock in the class Process instead of class Send. Good Heaven's python's threading rocks! I stress tested the server script having two clients sending requests on a while 1 loop without even a time.sleep() and yet it still runs! ^_^ class Process(threading.Thread): lock = threading.Lock() # Lock instance should be placed here def __init__(self,query) self.query = query threading.Thread.__init__(self) def run(self): ''' Some data processing code here ''' Process.lock.acquire() cursor.execute(query) Process.lock.release() class Send(Request__POA.Send): def push(self,query,...some args here): Process(query).start() db = MySQL().connect() cursor = db.make_cursor() -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading.Lock() question
@ Dennis Thanks for the quick heads up! You're right! I noticed the bug on my script just after sending out my question. Yes, I'm using MySQLdb but I did a wrapper for it to further simplify my script that why the sample script I wrote is a little bit different. Thanks again! Python rules!!! ^_^ -- http://mail.python.org/mailman/listinfo/python-list
Fetching the Return results of a spawned Thread
Is there any way to fetch the Return results of spawned threads within the parent script? I would like to do that because I'm having problems with Threads that do queries to a database, I often encounter Threads failing due to MySQL connection failures. As much as possible I plan to make the threads return the query string and let the parent script do the actual query. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fetching the Return results of a spawned Thread
Thanks a lot for the links that you gave me. I will look into that today! :-) -- http://mail.python.org/mailman/listinfo/python-list
Multi-Threading Practices
Greetings, I was the last time who asked your opinion about Infinite Loops and crontab. I settled with crontab where in the python program selects a number of records from a mysql database and then releases Threads (which is actually CORBA clients) that report to a CORBA server, wait a response and mark the record as done if everything's working fine. The crontab is scheduled to run every 1 minute. My question is this: Is there any way I could manage the number of threads to release? How can I kill a certain Thread if its inactive for sometime? Also I encountered some bottleneck problems on mysql. What's the best way to avoid these problems? Thanks in advance and more power to python! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Is inifinite loop not a good practice?
Thanks for the quick heads up! The comparison between implementing an infinite loop and cron is great. I'm beginning to see cron as the better solution between the two specially during crash instances. I'll try to code the script using the two solutions and do some stress testing to determine which is better between those two. -- http://mail.python.org/mailman/listinfo/python-list
Is inifinite loop not a good practice?
Greetings, I have to write a python script that would continously monitor and process a queue database. Once the script sees an unprocessed record it will create a thread to process it otherwise it will do nothing. I've been planning to do an infinite loop within the script to do this but I've been hearing comments that infinite loop is a bad programming practice. I'm opted to run the script via crontab but I consider it as my last resort. Do you have any suggestions on the design? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
SMPP implementation in python
Greetings! Does anyone know a good reference on how to implement SMPP in python. I can't find any besides NET::SMPP in perl and I don't want to get my hands for that. Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Any wing2.0 users here?
emacs has been my long time companion for php, perl, and python. My boss recommended to me Wing2.0, I find it hard to adjust though. What can you say about this IDE? He say's if I think it could improve my productivity he's willing to buy it for me. Suggestions for better python IDE's are welcome! Thanks in advance! ^_^ -- http://mail.python.org/mailman/listinfo/python-list
Re: Any wing2.0 users here?
Thanks for all the recommendations! I took a look on wingide2.0 on my linux box and it seems pretty good and has a lot of nifty features (which is pretty daunting to use since I've been programming with no IDE at all) and it debugger work pretty well but for a price tag of $179 I think it not worth it. Thanks for recommending me PyDev and TruStudio, I've been trying to get my hands on eclipse for a long time! ^_^ A little bit OT, I too have been programming python without a debugger, I got used to php's lack of debugger. Thanks again guys! -- http://mail.python.org/mailman/listinfo/python-list
getting the status codes from the ftplib module
I'm writing a simple python code that will upload files onto a ftp server. Everything's fine and working great except that the script I wrote don't know is an upload is successful or not. Is there a way to obtain the ftp status codes with this module? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: getting the status codes from the ftplib module
[EMAIL PROTECTED] wrote: Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Re: python bug in this list implementation? (Fredrik Lundh) 2. Re: python coding contest (Bengt Richter) 3. Re: python coding contest (Roman Susi) 4. Re: sorting with expensive compares? (Stuart D. Gathman) 5. Re: Timing out arbitrary functions (antti kervinen) 6. Re: python coding contest (Duncan Booth) 7. Re: Patch : doct.merge (Nicolas Lehuen) 8. Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF (Martin P. Hellwig) 9. getting the status codes from the ftplib module (Alvin A. Delagon) 10. Re: getting the status codes from the ftplib module (Fredrik Lundh) Subject: Re: python bug in this list implementation? From: "Fredrik Lundh" [EMAIL PROTECTED] Date: Wed, 28 Dec 2005 08:50:47 +0100 To: python-list@python.org To: python-list@python.org Chris Smith wrote: I've been working on some multi-dimensional lists and I've encountered some very strange behaviour in what appears to be simple code, I'm using python 2.4.2 and IDLE. If anyone can tell me why it's behaving so strange please let me know, any improvements to my general coding style are also appreciated. code below: import sys import copy grid = [] oGrid = [] sGrid = [] def createGrid(): f = open(r"...sudoku.txt", "rb") ## see attached for the file. for line in f: aLine = line.strip().split(',') if aLine != [""]: for i in xrange(len(aLine)): aLine[i] = int(aLine[i]) grid.append(aLine) at this point, grid contains a list of lists. oGrid = copy.deepcopy(grid) if you assign to a name inside a function, that name is considered to be *local*, unless you specify otherwise. in other words, this doesn't touch the *global* (module-level) oGrid variable. sGrid.append(copy.deepcopy(grid)) here you add a list of lists to a list. the result is a list with a single item. def printGrid(): print "original grid:" for line in oGrid: print line#why doesn't this print anything? because the *global* oGrid is still empty. print "S grid:" for line in sGrid: print line #this prints the grid but the formatting is all over the place. because sGrid contains a single item; a copy of your original grid. print "Iteration grid: " for line in grid: print line #works fine! as expected. I suggest reading up on list methods and global variables in your favourite python tutorial. also read: http://www.catb.org/~esr/faqs/smart-questions.html#id3001405 /F Subject: Re: python coding contest From: [EMAIL PROTECTED] (Bengt Richter) Date: Wed, 28 Dec 2005 08:09:51 GMT To: python-list@python.org To: python-list@python.org On 27 Dec 2005 09:24:44 GMT, Duncan Booth [EMAIL PROTECTED] wrote: Scott David Daniels wrote: I definitively need a new algorythm. g And I am sadly stuck at 169. Not even spitting distance from 149 (which sounds like a non-cheat version). Throw it away and start again with a fresh (clean) solution. That's what I did when I'd reached the limit of nested maps and lambdas at 150 characters. I'm now on 134 characters and the solution is very nearly legible. (Frustratingly, I'm away for the next few days, so I may not get a chance to submit my solution). It would be a nice idea to come up with a scoring system which better reflects Python's ideals. For example, use the parser in Python to count up various syntactic elements, score 0 for comments, indents, dedents, newlines, docstrings, 1 for each name or operation used and higher scores for things like lambda or overly complex expressions. [23:28] C:\pywk\clp\seven\pycontest_01py24 test.py . -- Ran 1 test in 0.391s OK [23:28] C:\pywk\clp\seven\pycontest
urllib http status codes
Greetings! Is there any way I can obtain the HTTP status codes when using the urllib module? As of now I can only think of doing a regex on the result of the read(). Thanks in advance! ^_^ -- http://mail.python.org/mailman/listinfo/python-list
Re: getting the status codes from the ftplib module
I'm very sorry, newbie here! @_@ I'm still getting the hang of Thunderbird. -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib http status codes
Thanks! Will try httplib! ^_^ -- http://mail.python.org/mailman/listinfo/python-list
SOAPpy module
Hello fellow pythonista's! I would like to ask if there's any good people who had experience in using the SOAPpy module. I'm currently rewriting a SOAP client that is written in PERL which uses the SOAP::Lite module. I managed to fetch the XML response from the server but I'm getting XML parser errors. I turned on the SOAP debug mode so that I could check the Incoming SOAP message and it was ok. :o Has anyone experienced this? I'm googling like crazy these past few weeks just to find a solution to this predicament. Thank you in advance! :-) -- http://mail.python.org/mailman/listinfo/python-list
Any SOAPpy users here?
Hello python programmers! I would like to add myself to the ever increasing number of python users. Here's my first question. I've written two SOAP clients using PERL and a PHP. I tried to wirte a new SOAP client using python but I'm having problems. First, I can't seem to find a good documentation of the SOAPpy module. Second, I found a code snippet of a python SOAP client but it was designed only to use the SOAPproxy function. How can I create a python SOAP client given these parameters: URI: urn:TESTWS HOST: https://hostname/cgi-bin/server.cgi Here's the PERL snippet that I'm trying to convert into a pythinic language: my $login = SOAP::Lite - uri ($URL) - proxy ($host) - login($uname, $epwd); my $result = $login -result; Help will be greatly appreciated. Thank you in advance and more power to python programmers! -- http://mail.python.org/mailman/listinfo/python-list
Writing python SOAP client
Hello python programmers! I would like to add myself to the ever increasing number of python users. Here's my first question. I've written two SOAP clients using PERL and a PHP. I tried to wirte a new SOAP client using python but I'm having problems. First, I can't seem to find a good documentation of the SOAPpy module. Second, I found a code snippet of a python SOAP client but it was designed only to use the SOAPproxy function. How can I create a python SOAP client given these parameters: URI: urn:ECASHWS HOST: https://hostname/cgi-bin/server.cgi Here's the PERL snippet that I'm trying to convert into a pythinic language: my $login = SOAP::Lite - uri ($URL) - proxy ($host) - login($uname, $epwd); my $result = $login -result; Help will be greatly appreciated. Thank you in advance and more power to python programmers! -- http://mail.python.org/mailman/listinfo/python-list