En Sat, 04 Aug 2007 18:52:16 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió:
>> On Aug 2, 7:32 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:> >> If your web server is multithreaded (or you use some other way to >> process >> > many simultaneous requests) you have to be more careful - remember >> that >> > sys.stdout is global, you must find a way to distinguish between >> output >> > from different processes all going into the same collector. > > I'm actually worried about this now. Does anyone know of any > potential solutions? Anything to at least get me started? You can use threading.currentThread() to distinguish between threads, and a Lock (or RLock) to ensure the output doesn't get mixed: def write(msg): t = time.strftime("%x %X", time.localtime()) who = threading.currentThread().getName() line = "%s (%-15.15s) %s\n" % (t, who, msg) OutputDebugString("%s (%-15.15s) %s\n" % (t, who, msg)) loglock.acquire() try: with logfile() as f: f.write(line) finally: loglock.release() -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list