[Tutor] time.sleep does not return at turn of the hour!!!

Mohamed Lrhazi mohamed at your-site.com
Sun Nov 7 07:17:48 CET 2004


Yes. I actually did try that before and it does not hang!
So you're right, it must be hanging somewhere else...

I will try to narrow it down more...

Thanks,
Mohamed~

--On Saturday, November 06, 2004 11:03 PM -0500 Kent Johnson 
<kent_johnson at skillsoft.com> wrote:

> What if you take out the file stuff and just do the sleep? For example
> this works fine for me (Win2K, Python 2.3.4):
>  >>> from time import strftime, sleep
>  >>> while True:
> ...   sleep(1)
> ...   print strftime('%H:%M:%S')
> ...
>
> Kent
>
> At 10:03 PM 11/6/2004 -0500, Mohamed Lrhazi wrote:
>> Hello all,
>>
>> I am stuck with is strange problem. Here is the srouce:
>>
>> ...
>> while 1:
>>                         self.where=self.fp.tell()
>>                         inbuffer=self.fp.read(self.inbuffersize)
>>                         if not inbuffer:
>>                                 if self.onefile:
>>                                         self.lines=["DONE"]
>>                                         break
>>                                 new_filename=self.makeFileName()
>>                                 if not new_filename == self.filename:
>>                                         old_filename=self.filename
>>                                         self.fileShift()
>>                                         fileshifted=1
>>                                         passe=0
>>                                         break
>>                                 passe=passe+1
>>                                 # if not passe % 60:
>>                                 log.logLine('logStream.refillLines',"%d:
>> Waiting for new lines..."%(passe))
>>                                 time.sleep(1) #It seems at the turn of
>> the hour, we dont wakeup at all from this call!!!
>>                                 log.logLine('logStream.refillLines',"%d:
>> Woke up..."%(passe))
>>                                 self.fp.seek(self.where)
>>                         else:
>>                                 self.bytesRead = self.bytesRead +
>> len(inbuffer)
>>
>> ...
>>
>> Here is the output:
>>
>> 1106 20:59:56:logStream.refillLines: 7: Waiting for new lines...
>> 1106 20:59:57:logStream.refillLines: 7: Woke up...
>> 1106 20:59:57:logStream.refillLines: 8: Waiting for new lines...
>> 1106 20:59:58:logStream.refillLines: 8: Woke up...
>> 1106 20:59:58:logStream.refillLines: 9: Waiting for new lines...
>> 1106 20:59:59:logStream.refillLines: 9: Woke up...
>> 1106 20:59:59:logStream.refillLines: 10: Waiting for new lines...
>>
>>
>> It just hangs there... till I control-C and then:
>>
>> Traceback (most recent call last):
>>  File "./parseDaemon.py", line 355, in ?
>>    l=zeusLog.getNextLine()
>>  File "./parseDaemon.py", line 237, in getNextLine
>>    self.refillLines()
>>  File "./parseDaemon.py", line 206, in refillLines
>>    time.sleep(1) #It seems at the turn of the hour, we dont wakeup at
>>    all  from this call!!!
>> KeyboardInterrupt
>>
>>
>> This happens systematically and only when we turn to the next Hour!!!
>>
>> I tried with both python python-2.2.3-7 and python2.3-2.3.3-2pydotorg
>> I am using Fedora Core 1
>>
>> Any ideas?
>>
>> Thanks,
>> Mohamed~
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor






More information about the Tutor mailing list