Please help with Threading
Cameron Simpson
cs at zip.com.au
Mon May 20 05:54:19 EDT 2013
On 20May2013 19:09, Chris Angelico <rosuav at gmail.com> wrote:
| On Mon, May 20, 2013 at 6:35 PM, Cameron Simpson <cs at zip.com.au> wrote:
| > _lock = Lock()
| >
| > def lprint(*a, **kw):
| > global _lock
| > with _lock:
| > print(*a, **kw)
| >
| > and use lprint() everywhere?
|
| Fun little hack:
|
| def print(*args,print=print,lock=Lock(),**kwargs):
| with lock:
| print(*args,**kwargs)
|
| Question: Is this a cool use or a horrible abuse of the scoping rules?
I carefully avoided monkey patching print itself:-)
That's... mad! I can see what the end result is meant to be, but
it looks like a debugging nightmare. Certainly my scoping-fu is too
weak to see at a glance how it works.
--
Cameron Simpson <cs at zip.com.au>
I will not do it as a hack I will not do it for my friends
I will not do it on a Mac I will not write for Uncle Sam
I will not do it on weekends I won't do ADA, Sam-I-Am
- Gregory Bond <gnb at bby.com.au>
More information about the Python-list
mailing list