Re: Is crawling the stack "bad"? Why?

2008-02-29 Thread Stephen Hansen
> > > Seriously, crawling the stack introduces the potential for disaster in > > your program, since there is no guarantee that the calling code will > > provide the same environment i future released. So at best you tie your > > solution to a particular version of a particular implementation of >

Re: Is crawling the stack "bad"? Why?

2008-02-29 Thread Diez B. Roggisch
> > I will (mostly)... I knew it was bad code and a total hack, I just was > looking for a concise reason as to why. > > I appreciate the comments, guys... thanks! There is another one: crawling the stack is O(n), whilst using thread-local storage is O(1) Diez -- http://mail.python.org/mailm

Re: Is crawling the stack "bad"? Why?

2008-02-28 Thread Russell Warren
> OK, if you crawl the stack I will seek you out and hit you with a big > stick. Does that affect your decision-making? How big a stick? :) > Seriously, crawling the stack introduces the potential for disaster in > your program, since there is no guarantee that the calling code will > provide the

Re: Is crawling the stack "bad"? Why?

2008-02-26 Thread Carl Friedrich Bolz
Paul Rubin wrote: > Russell Warren <[EMAIL PROTECTED]> writes: >> That is exactly where I started (creating my own request handler, >> snagging the IP address and stashing it), but I couldn't come up with >> a stash location that would work for a threaded server. > > How about a dictionary indexed

Re: Is crawling the stack "bad"? Why?

2008-02-26 Thread Steve Holden
Russell Warren wrote: > Thanks Ian... I didn't know about threading.local before but have been > experimenting and it will likely come in quite handy in the future. > For this particular case it does basically seem like a replacement for > the threadID indexed dictionary, though. ie: I'll still ne

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Russell Warren
Thanks Ian... I didn't know about threading.local before but have been experimenting and it will likely come in quite handy in the future. For this particular case it does basically seem like a replacement for the threadID indexed dictionary, though. ie: I'll still need to set up the RpcContainer,

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Ian Clark
On 2008-02-25, Russell Warren <[EMAIL PROTECTED]> wrote: > >> the threading.local class seems defined for that purpose, not that I've ever >> used it ;) > > I hadn't heard of that... it seems very useful, but in this case I > think it just saves me the trouble of making a stash dictionary... > unle

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Russell Warren
> How about a dictionary indexed by by the thread name. Ok... a functional implementation doing precisely that is at the bottom of this (using thread.get_ident), but making it possible to hand around this info cleanly seems a bit convoluted. Have I made it more complicated than I need to? There

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Boris Borcic
Paul Rubin wrote: > Russell Warren <[EMAIL PROTECTED]> writes: >> That is exactly where I started (creating my own request handler, >> snagging the IP address and stashing it), but I couldn't come up with >> a stash location that would work for a threaded server. > > How about a dictionary indexed

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Paul Rubin
Russell Warren <[EMAIL PROTECTED]> writes: > That is exactly where I started (creating my own request handler, > snagging the IP address and stashing it), but I couldn't come up with > a stash location that would work for a threaded server. How about a dictionary indexed by by the thread name. It

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
> That is just madness. What specifically makes it madness? Is it because sys._frame is "for internal and specialized purposes only"? :) > The incoming ip address is available to the request handler, see the > SocketServer docs I know... that is exactly where I get the address, just in a mad wa

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Paul Rubin
That is just madness. The incoming ip address is available to the request handler, see the SocketServer docs. Write a request handler that stashes that info somewhere that rpc responders can access it in a sane way. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
Argh... the code wrapped... I thought I made it narrow enough. Here is the same code (sorry), but now actually pasteable. --- import SimpleXMLRPCServer, xmlrpclib, threading, sys def GetCallerNameAndArgs(StackDepth = 1): """This function returns a tuple (a,b) where: a = The name of the ca

Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
I've got a case where I would like to know exactly what IP address a client made an RPC request from. This info needs to be known inside the RPC function. I also want to make sure that the IP address obtained is definitely the correct one for the client being served by the immediate function call