<div dir="ltr">Sometimes, I notice the below errors:<div><div> python call_Test.py</div><div>Traceback (most recent call last):</div><div>  File "call_Test.py", line 1, in <module></div><div>    from Test_Task import TestTask</div>
<div>  File "/cygdrive/d/smoketest/targetflasher/flasher_server/Source/Test_Task.py", line 5, in <module></div><div>    import Logging.logQueueHandler as logq</div><div>  File "/cygdrive/d/smoketest/targetflasher/flasher_server/Source/Logging/logQueueHandler.py", line 72, in <module></div>
<div>    queue = multiprocessing.Queue(-1)</div><div>  File "/usr/lib/python2.6/multiprocessing/__init__.py", line 213, in Queue</div><div>    return Queue(maxsize)</div><div>  File "/usr/lib/python2.6/multiprocessing/queues.py", line 37, in __init__</div>
<div>    self._rlock = Lock()</div><div>  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 117, in __init__</div><div>    SemLock.__init__(self, SEMAPHORE, 1, 1)</div><div>  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 49, in __init__</div>
<div>    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)</div><div>OSError: [Errno 17] File exists</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 2, 2013 at 4:13 PM, Maitrey Mishra <span dir="ltr"><<a href="mailto:maitreymishra23@gmail.com" target="_blank">maitreymishra23@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I wrote some tests for logging module. I use python 2.6 and use the example as in cookbook</div><div>
file : Test_Task.py</div><div>from threading import Thread</div><div>import Logging.logQueueHandler as logq</div>
<div><br></div><div>class TestTask(threading.Thread):</div><div>def __init__(self):</div><div>pass</div><div><br></div><div>def run(self):</div><div>t = Thread(target=logq.log, args=("ERROR", "Hi"))</div>

<div>t.start()</div><div>q = Thread(target=logq.log, args=("ERROR", "Hello"))</div><div>q.start()</div><div>p = Thread(target=logq.log, args=("ERROR", "How are you?"))</div><div>p.start()</div>

<div>l = Thread(target=logq.log, args=("ERROR", "I am fine, Thank You!"))</div><div>l.start()</div><div>call_test.py</div><div>from Test_Task import TestTask</div><div>import unittest</div><div><br></div>

<div>task = TestTask()</div><div>task.run()</div><div>However, In the log messages I see a number of messages missing.</div><div>With the tests, my aim is to see how logging works with multiple threads.</div></div><div class="HOEnZb">
<div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Apr 26, 2013 at 3:19 PM, Jean-Michel Pichavant <span dir="ltr"><<a href="mailto:jeanmichel@sequans.com" target="_blank">jeanmichel@sequans.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">Yep that's the one I used.<br><br><hr><div><div><blockquote style="padding-left:5px;font-size:12pt;font-style:normal;margin-left:5px;font-family:Helvetica,Arial,sans-serif;text-decoration:none;font-weight:normal;border-left:2px solid #1010ff">

<div dir="ltr">Ah, <a href="http://plumberjack.blogspot.de/2010/09/using-logging-with-multiprocessing.html" target="_blank">http://plumberjack.blogspot.de/2010/09/using-logging-with-multiprocessing.html</a><div>I use this now, it seems to work!</div>


<div>Thanks!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 26, 2013 at 2:16 PM, Maitrey Mishra <span dir="ltr"><<a href="mailto:maitreymishra23@gmail.com" target="_blank">maitreymishra23@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div>Thanks for the inputs.</div><div>I use python2.6. It seems to be easier with python3.2 and QueueHandler class.</div>


<div>I pasted the class in my code however I still get the error: AttributeError: 'module' object has no attribute 'QueueHandler'</div>
<div>What changes did you do for adapting to python2.5?</div><div><br></div><div>Thanks!<br>Br,</div><div>Maitrey</div><div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Thu, Apr 25, 2013 at 4:32 PM, Jean-Michel Pichavant <span dir="ltr"><<a href="mailto:jeanmichel@sequans.com" target="_blank">jeanmichel@sequans.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



----- Original Message -----<br>
> Hi,<br>
><br>
> I need an efficient way of logging using python.<br>
> My problem statemnt:<br>
> 1. I have multiple processes using the same logging file.<br>
> I need solutions to the following:<br>
<div>> a) If multiple processes are trying to write to the same file, I need<br>
</div>> to prevent that. Otherwise, the logging messages will be puzzling to<br>
> the user as he would see logging messages from one module than may<br>
> be some other following it.<br>
><br>
> Please let me know if there is an efficient way to do it.<br>
><br>
> Thanks!<br>
><br>
> Br,<br>
> Maitrey<br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br>
Everything you need should be explained here<br>
<a href="http://docs.python.org/release/3.2/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes" target="_blank">http://docs.python.org/release/3.2/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes</a><br>




<br>
Most of the concepts are applicable to any version of python I've done it with python 2.5. I used some Vinay's code posted on the net to implement a logging server, all my processes are logging to that server which is responsible for writing the file.<br>




<br>
JM<br>
<br>
<br>
-- IMPORTANT NOTICE:<br>
<br>
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.<br>




</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</blockquote><br></div></div></div><div><div><font face="monospace"><br>
<br>
-- IMPORTANT NOTICE: <br>
<br>
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.</font></div>

</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>